Question: Python Instead of using an array, as the QueueLab did, here you will use a Linked List from your language's library. Implement all the methods
Python
Instead of using an array, as the QueueLab did, here you will use a Linked List from your language's library. Implement all the methods of Stack : enqueue(), dequeue(), size(), printQueue(), etc, using calls to the linked list methods that correspond to the actions need. In the array implementation, you wrote code to manipulate the array. For this linked list implementation, methods already exist. You do not need maxSize, comment this out and explain why it's not needed. You possilby do not need other attributes, comment these out and explain why they may not be needed. Before the underlying implementation of queue was array, now the underlying implementation of queue will be Linked list.
class Queue: def __init__(self, max_size=5): self.head = -1 self.tail = -1 self.size = 0 self.max_size = max_size # TODO comment self.items = ["" for x in range(max_size)] # TODO comment def is_empty(self): def is_full(self): def enqueue(self, item): def dequeue(self): def peek(self): def size(self): def print_queue(self): stack_str = "" return stack_str;
class QueueEmptyException(Exception): pass
class QueueFullException(Exception): pass
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
