Skip to content

Conversation

@amirsoroush
Copy link

Currently FIFO is not working correct.

In the following example "Ant" should come before "Lion":

>>> h = PriorityQueueHeap()
>>> h.insert(2, "Bat")
>>> h.insert(2, "Cat")
>>> h.insert(18, "Rat")
>>> h.insert(2, "Ant")
>>> h.insert(2, "Lion")
>>> h.insert(4, "Bear")
>>> 
>>> for i in range(h.size):
...     n = h.delete_at_root()
...     print(n)
... 
Bat
Cat
Lion
Ant
Bear
Rat
>>> 

The proposed change will fix this issue.

I also (just like #13) terminated the iteration as soon as we find out that there is no need to swap the values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant