Question: Q. Part-1:Modify the LLStack.py file into LLQueue.py. The LLQueue.py file should implement a queue using a linked list. Once you have this created, write a
Q. Part-1:Modify the LLStack.py file into LLQueue.py. The LLQueue.py file should implement a queue using a linked list. Once you have this created, write a test program to fully test the methods of the LLQueue.py file
.Part-2: A priority queue is a queue that allows certain entities to be moved to the front of the queue. For example, in an emergency room, if somesone comes in with severe injury or illness, they are moved to the front in order to be treated before the others already in the queue.
Part-3:Modify the LLQueue.py file you created above that allows protity entities to be moved to the fornt of the queue. Write a unique test program that regular nodes and priority nodes to be added to and removed from queue.Note:Class function for Node and ILLStack function is below:
class Node: def __init__(self,initdate): self.data=initdata self.next=None def getData(self,data): return self.data def getNext(self): return self.next def setData(self,newData): self.data=newData def setNext(self,newnext): self.next=newnext
class LLStack: def __init__(self): self.head=None def isEmpty(self): return self.head==None def push(self,item): temp=Node(item) temp.setNext(self.head) self.head=temp def pop(self): item=self.head.getData() self.head=self.head.getNext() return item def length(self): current=self.head count=0 while current!=None: count+=1 current=current.getNext() return count def printList(self): current=self.head while current!=None: print(current.getData(),end=" ") current=current.getNext() print()
Note: Stack and Node class must be separated from main function; and three part should be answered separately and must use python language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
