Python代写:CP164 Stacks代做留学生Python语言

Introduction这次需要代写的是一个关于Stack的Lab作业,由于是Lab作业,工作量并不大,都是基本的Stack操作。Requirementsing Versus Extending an ADTNote: In this and future labs we make a distinction between using an ADT and extending an ADT. You must be clear on this distinction:Using an ADTWhen asked to use an ADT write a program that is implementation independent, i.e. the program uses only ADT methods (such as those for a stack) and works for either the array or linked implementation of a data structure. Do not change any code in the ADT implementation files such as stack_array.py.Extending an ADTWhen asked to extend an ADT you are going to add new methods to an ADT, meaning that you are going to add code to one or both of the array or linked implementation of a data structure, such as stack_array.py.The Stack ADT (Abstract Data Type)A stack is a data structure that follows LIFO (Last In, First Out) rules. Data is added to the top of a stack and removed from the top of a stack. The Stack ADT provides methods for manipulating data in a stack.A reminder of some important points of ADT use are:No matter what the underlying implementation of the stack programs should access a stack only through these methods.As a corollary to the first point, the stack can be implemented in any number of ways so long as any given implementation follows the ADT function requirements. The implementation must invisible to the program using the Stack ADT.A stack may store any type of data, although all the data it stores should be of the same type.The following code imports a stack class and the Food class then initializes a stack:12345from stack_array import Stackfrom food import Foods = Stack()…The line:1from stack_array import Stackimports the Stack class from the library file stack_array.py. This library file can be replaced by any other file that implements the Stack ADT methods.The line:1from food import Foodgives access to the methods in the food.py library file as above.The line:1s = Stack()creates a stack named s. The stack is now ready to accept data.Project ReferencesAs we work through the term we will be creating a number of different data structures and adding more functionality to the Food library already written. Making sure that each new project has the latest version of a data structure or Food library is difficult to do if we are reduced to copying and pasting our pydev modules into each new project. Fortunately, Eclipse provides a much better mechanism to reference code. Setting up Project References allows you to link one Pydev project to another, and to use the code from one project in another with the import and from … import * statements already shown. Nothing needs to be changed in your source code.To make a reference from one project to another in Eclipse, right click on a project name in the Navigator pane. From the resulting pop-up menu click on Properties and then on Project References in the resulting dialog box.Click on the check box of all projects that you wish to reference from the current project. In this example the project album is already selected, and the project data_structures will be added as a reference. Once this is done all of the classes in both album and data_structures will be available through import statements.A few things to keep in mind when using project references:All referenced projects must be open when attempting to run a program.Submit all referenced projects as part of your Eclipse archive (.zip) file when submitting exercises or the markers will not be able to run your programs. You may select multiple projects to include in an Eclipse archive file.Do not use the same Pydev module names in two different referenced projects or Eclipse will not know which one an import statement is supposed to be referring to.Project references go one way only. If the project stacks references the project data_structures, then data_structures should not reference stacks. Circular references are a very bad idea.Upon occasion referenced projects may become ‘out of sync’ with the project that references them. To fix this, right-click on the project and choose Refresh to update Eclipse from the file system.Array-based StacksThe file stack_array.py is a text file containing the basic outline of the array-based Stack class. Copy this code into the Pydev module stack_array.py in your login_data_structures project (where login is your Network login). Thus, a student with the Network login barn4520 should name their projects barn4520_Food and barn4520_data_structures.) The Lab Instructor will walk you through this library and discuss its inner workings.Tasks(If you were unable to complete Lab 1 correctly, you may use these files: food.py, food_utilities.py, and foods.txt as the basis for your lab. These files will not be available until after the labs for the previous week are completed.)For the appropriate tasks you may download and use the Food class definition in food.py from Lab 1.For all of your data structures (stacks, queues, BSTs, etc.), put your code into libraries in your Pydev project login_data_structures.For the stack_array library complete the implementations of the is_empty, pop, and peek methods. These methods extend the Stack ADT.Write and test the following function:12345678910111213def array_to_stack(s, a):“””——————————————————-Pushes contents of a onto s.Use: array_to_stack(s, a)——————————————————-Preconditions:s - a Stack object (Stack)a - a Python list (list)Postconditions:The contents of a are moved into s, a is empty.——————————————————-“””Add this function to a Pydev module named utilities in your login_data_structures project so that you have easy access to it later.Write and test the following function:12345678910111213def stack_to_array(s, a):“””——————————————————-Pops contents of s into a.Use: stack_to_array(s, a)——————————————————-Preconditions:s - a Stack object (Stack)a - a Python list (list)Postconditions:Contents of s are moved into a, s is empty.——————————————————-“””Add this function to the Pydev module named utilities in your login_data_structures project.Write and test the following function:1234567891011121314151617181920def stack_test(a):“””——————————————————-TestsUse: stack_test(a)——————————————————-Preconditions:a - list of data (list of ?)Postconditions:the methods of Stack are tested for both empty andnon-empty stacks using the data in a:is_empty, push, pop, peek——————————————————-“””s = Stack()# tests for the stack methods go here# print the results of the method calls and verify by handreturnAdd this function to the Pydev module named utilities in your login_data_structures project.Use a list of integers to test your stack code.Re-use stack_test, but this time pass it a list of Food data. (Use the data in foods.txt).本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp

你可能感兴趣的:(Python代写:CP164 Stacks代做留学生Python语言)