Question: (d) (12 marks) We have provided a print operation print() that you can use to print out the queue. Test your code. You may use
(d) (12 marks)
We have provided a print operation print() that you can use to print out the queue. Test your code. You may use additional print statements to explain what you are testing with each test. Make sure you test for each of the three cases:
- insert into an empty queue
- insert at the front of the queue
- insert after some existing node.
------------
PREVIOUS Question
"" return self.head == None
def print(self) -> None: """Print out the queue""" if self.head == None: print('The queue is empty') else: current = self.head while current != None: print(current.item, current.priority) current = current.next
def insert(self, item: object, priority_value: int) -> None: """Insert item according to priority. Preconditions: true Postconditions: post-self is the sequence pre-self with item inserted after the last item in self with the same priority """
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
