Both self-balancing binary trees and heaps are reasonable data structure choices for the Priority Queue ADT. In this lab you will experiment with two Priority Queue implementations, one based on Java's PriorityQueue class (which uses a heap) and one based on Java's TreeMap class (which uses a red-black tree).
TreeMinQueue.java
- Implementation based on Java's TreeMap class. YOU NEED TO IMPLEMENT THIS. (Note that this implementation will not allow duplicate priorities, since Map classes do not allow duplicate keys.)TreeMinQueue.java
and confirm that it works
correctly using the provided unit tests.PriorityQueueTimer.java
. Consult
with your group to make predictions about which operations (if
any) will be faster for the heap implementation and which will be
faster for the BST implementation. Run the code to see if your
predictions were correct.Post your timing results to the Canvas discussion. You should discuss your results with your team members and make sure you understand them.
Based on your results, under what circumstances would a heap-based implementation be preferable to a BST-based implementation? Under what circumstances would a BST-based implementation be preferable?