The java API: java.sun.com/j2se/1.3/docs/api/
Lab 6:
Priority Queue Application
- Download the following file
- Study the Heap implementation of the Priority Queue ADT present in
HeapPriorityQueue.java
- study specifically insert and removeMin methods in that class.
- Implement a test class that uses a Priority Queue to return the kth smallest
element in a list.
- Assume the first argument is the value of k, and the list after are the
elements list.
- Assume the key and the element are the same at each node.
- Compile and run your code with different arguments
Assuming the test class name is PQTest and we are looking for the fifth
smallest element in the set {2,10,7,13,4,18,11,16,3}. we use:
> java PQTest 5 2 10 7 13 4 18 11 16
3
--------------------------------------------------------------------------------
The 5th smallest element is 10
--------------------------------------------------------------------------------