Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with a python script that can run the following thanks for your help

ID: 3759986 • Letter: P

Question

Please help with a python script that can run the following thanks for your help!

Write a container class called PriorityQueue. The class should support methods:

• insert(): Takes a number as input and adds it to the container

• min(): Returns the smallest number in the container

• removeMin(): Removes the smallest number in the container

• isEmpty(): Returns True if container is empty, False otherwise

The overloaded operator len() should also be supported.

>>> pq = PriorityQueue()

>>> pq.insert(3)

>>> pq.insert(1)

>>> pq.insert(5)

>>> pq.insert(2)

>>> pq.min()

1

>>> pq.removeMin()

>>> pq.min()

2

>>> len(pq) 3

>>> pq.isEmpty()

False

Explanation / Answer

>>> pq = PriorityQueue()
>>> pq.insert(3)
>>> pq.insert(1)
>>> pq.insert(5)
>>> pq.insert(2)
>>> pq.min()
1
>>> pq.removeMin()
>>> pq.min()
2
>>> len(pq) 3
>>> pq.isEmpty()
False

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote