Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

python Programming Project Number 3: implementation of Stack and Queue Classes Stack AD puah, pap, top, aize, and -init. You should also implement a unit-testing

image text in transcribed

python

Programming Project Number 3: implementation of Stack and Queue Classes Stack AD puah, pap, top, aize, and -init. You should also implement a unit-testing file for this class Queue ADT You are to define a Stack class which implenents the Stack ADT, that is, it will have the methods You are to define a Queue class which implements the Queue ADT, that is, it will have the methods enquene, dequeue, front, size, and ini. You should also implement a unit-testing file for this class. The two clames can be tested together by importing them into the palindrome py file provide Implementation Using Linked Structures Both classes, Stack aad Queue, will be implemented using a linked data strategy. That is, you will use LietNode objects from the elass of that name dofined in Chapter 4 You shoald import the file ListNode.py into your project for that purpose, Warning: you will not receive credit if you detine your Stack (or Queue) class using the LList elsss defined in the text, even though it uss LiatNodes-it has the same interface as a Python List, so you would not be cresting any new cocle. You must use the List Node class directly in your implementations. The hints in the bext section give you ways you can still use LiatNodea using coding ileas from LList class methods Hints on Implementation Using Linked Structures A Stack is accessible at one end only, its top. This correspobds exactly to the lhead attribute of a linked list. Pushing and lopping is then tast adding a node to ar renoving A hode from the load of a linked list. You can ise code from the LLiat class of Chapter , making ay Dcessary wodifications. For example, if the LList class, han an attribute called head, then fr the Stack claw, ehange the code so that the attribute is ealled top A queue must be accessed from either of two cnids, its froat or its back. Thre linked stracture for a queue will therefore ned two attributes. front and back. ollow the plhilosophy of thinking all ADT attribates as pevste, using an underscore as the first chiaracter. In languages like ++, this will indicate privacy which can be enforoed.) The deqeue methoxl shonld be iuplenented exactly like the enqueue met hod will pop tmet hod of the Stack class, removing a node fron the frout of the Queue. Tlu more conplicated, since it ast add a nen LiatNode object to the hack of the Queue Oae more warning about inmplemesting tle Queue class: there is alrely a Queue uodule in the Python library, so if you try to implenment yolur queue cluss in a fike calnd Queue.py aad then try to say fros Queue inport Queue it will ot e your file. You unst call your file MyQueue. py and yoiu imist say from MyQueue inport Queue Chapter 5 slims an example of usang the Queue elaks ihih dors exactly this, in palindrone Py Finally, in exploting programming techniques using linked steuctures, always draw lxx-and-aTow diagrams to illustrate the Python statements of the metluds you write, as we have doue ia class and in the text. Programming Project Number 3: implementation of Stack and Queue Classes Stack AD puah, pap, top, aize, and -init. You should also implement a unit-testing file for this class Queue ADT You are to define a Stack class which implenents the Stack ADT, that is, it will have the methods You are to define a Queue class which implements the Queue ADT, that is, it will have the methods enquene, dequeue, front, size, and ini. You should also implement a unit-testing file for this class. The two clames can be tested together by importing them into the palindrome py file provide Implementation Using Linked Structures Both classes, Stack aad Queue, will be implemented using a linked data strategy. That is, you will use LietNode objects from the elass of that name dofined in Chapter 4 You shoald import the file ListNode.py into your project for that purpose, Warning: you will not receive credit if you detine your Stack (or Queue) class using the LList elsss defined in the text, even though it uss LiatNodes-it has the same interface as a Python List, so you would not be cresting any new cocle. You must use the List Node class directly in your implementations. The hints in the bext section give you ways you can still use LiatNodea using coding ileas from LList class methods Hints on Implementation Using Linked Structures A Stack is accessible at one end only, its top. This correspobds exactly to the lhead attribute of a linked list. Pushing and lopping is then tast adding a node to ar renoving A hode from the load of a linked list. You can ise code from the LLiat class of Chapter , making ay Dcessary wodifications. For example, if the LList class, han an attribute called head, then fr the Stack claw, ehange the code so that the attribute is ealled top A queue must be accessed from either of two cnids, its froat or its back. Thre linked stracture for a queue will therefore ned two attributes. front and back. ollow the plhilosophy of thinking all ADT attribates as pevste, using an underscore as the first chiaracter. In languages like ++, this will indicate privacy which can be enforoed.) The deqeue methoxl shonld be iuplenented exactly like the enqueue met hod will pop tmet hod of the Stack class, removing a node fron the frout of the Queue. Tlu more conplicated, since it ast add a nen LiatNode object to the hack of the Queue Oae more warning about inmplemesting tle Queue class: there is alrely a Queue uodule in the Python library, so if you try to implenment yolur queue cluss in a fike calnd Queue.py aad then try to say fros Queue inport Queue it will ot e your file. You unst call your file MyQueue. py and yoiu imist say from MyQueue inport Queue Chapter 5 slims an example of usang the Queue elaks ihih dors exactly this, in palindrone Py Finally, in exploting programming techniques using linked steuctures, always draw lxx-and-aTow diagrams to illustrate the Python statements of the metluds you write, as we have doue ia class and in the text

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions