[Solved]Python Fifo Queue Lab9pr1py Zybook Problem Please Use Node Class Used Linked Lists Lecture Q37041849
IN PYTHON ONLY
FIFO Queue lab9pr1.py, Zybook
For this problem, please use the Node class that we used for linkedlists during the lectures. For this please import the Node.py fileat the top of your file using:
from Node import *
A first-in first-out queue (FIFO Queue) is a data structure thatconceptually stores a linear list of items by providing thefollowing functionality:
• enqueue(item) appends the new item at the end (the tail) ofthe queue.
• dequeue() removes the first item (the head) from the queue andreturns it.
It returns None if the queue is empty.
• isEmpty() returns True if the queue is empty, and Falseotherwise.
Write a class Queue that uses a linked list to store a FIFOqueue, and that imple- ments the three methods enqueue, dequeue,isEmpty in constant time.
For this you have to store as attributes of the queue areference to the head, as well as to the tail of the queue, and youhave to store the size of the queue (the number of elements itcontains). The three attributes head, tail, sizehave to beinitialized in the constructor. Make sure that you implementenqueue, dequeue, isEmpty as methods (i.e., as part of the class)and not as functions (i.e., outside of the class). For testing,remember to also add a repr method that should return a stringstarting with head->, followed by all elements of the queueseparated by spaces, and ending with <-tail. Add a comment inthe code where you justify why the runtimes of enqueue, dequeue,isEmpty are constant. When your program is complete, you should beable to run testqueue.py and get the following result:
Queue now: head-> <-tail isEmpty? True Enqueuing a Queue now: head-> a <-tail Enqueuing b isEmpty? False Queue now: head-> a b <-tail Enqueuing c Queue now: head-> a b c <-tail Dequeued: a Queue now: head-> b c <-tail Dequeued: b Queue now: head-> c <-tail Enqueuing d Queue now: head-> c d <-tail Enqueuing e Queue now: head-> c d e <-tail Dequeued: c Queue now: head-> d e <-tail Dequeued: d Queue now: head-> e <-tail Dequeued: e Queue now: head-> <-tail isEmpty? True
Expert Answer
Answer to IN PYTHON ONLY FIFO Queue lab9pr1.py, Zybook For this problem, please use the Node class that we used for linked lists d… . . .
OR

