Question: ( 1 0 points ) Write a PriorityQueueList class that implements a priority queue using a singly linked list that is always kept sorted. Your
points Write a PriorityQueueList class that implements a priority queue using a
singly linked list that is always kept sorted. Your class needs the following components:
A constructor that initializes the list and a size instance attribute
A method that shows the list elements from head to tail
An enqueue method that traverses the list until finding the correct insertion point,
then inserts the new element into the list
A dequeue method that removes and returns the element at the head of the list. If
the list is empty, this method returns None.
A peek method that returns without removing the element at the head of the list.
If the list is empty, this method returns None.
You can reuse the Node class that we defined earlier for a singly linked list.
points Below the PriorityQueueList class definition in priorityqueuelist.py
write a program that does the following:
First, test your PriorityQueueList class.
Enqueue some elements into a PriorityQueueList object, then repeatedly peek and
dequeue until the queue becomes empty.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
