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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!