Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q. Part-1:Modify the LLStack.py file into LLQueue.py. The LLQueue.py file should

ID: 3816189 • Letter: Q

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 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

Explanation / Answer

class Node:
def __init__(selfNode, value = None, next = None):
selfNode.value = value
selfNode.next = next

def __str__(selfNode):
return 'Node ['+str(selfNode.value)+']'

class LinkedList:
def __init__(selfNode):
selfNode.first = None
selfNode.last = None

def insert(selfNode, x):
if selfNode.first == None:
selfNode.first = Node(x, None)
selfNode.last = selfNode.first
elif selfNode.last == selfNode.first:
selfNode.last = Node(x, None)
selfNode.first.next = selfNode.last
else:
current = Node(x, None)
selfNode.last.next = current
selfNode.last = current

def __str__(selfNode):
if selfNode.first != None:
currentNode = selfNode.first
out = 'LinkedList [ ' +str(current.value) +' '
while current.next != None:
current = current.next
out += str(current.value) + ' '
return out + ']'
return 'LinkedList []'

def clear(selfNode):
selfNode.__init__()