Question: Modify the LLQueue.py file you created above that allows protity entities to be moved to the front of the queue. Write a unique test program
Modify the LLQueue.py file you created above that allows protity entities to be moved to the front of the queue. Write a unique test program that regular nodes and priority nodes to be added to and removed from queue.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.
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()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
