Module 2: Priority Queues

Studio


Bad Priority Queue Implementations
Authors: Tim Heyer and Ron Cytron

Introduction

In lecture, you've learned several different data structures that can be used to implement a priority queue and the pros/cons for each. In this studio, you will implement two of these priority queues and examine where each shines over the other.

For reference, you should review the lecture slides on PQs as Unordered Lists and PQs as Ordered Arrays.

  1. Begin by opening the studio3 package in the studios source folder of your repository.
  2. Find and open PriorityQueue.java and examine the interface.
    • Name three data types that could serve as T.
    • Look at the Comparable interface.
    • Find a class there that you don't know yet, and visit it to see how it implements compareTo(…).
  3. The compareTo(…) method is of great interest for this and subsequent assignments. Given the call a.compareTo(b), which of the following is true?
    Discuss this among yourselves and present your answer to a TA.
  4. Open the UnorderedList.java class, complete the methods, and run the unit tests.
  5. Open the OrderedArray.java class, complete the methods, and run the unit tests.
  6. Open the UnorderedListExperimentInsert.java class.
  7. Run the experiment to collect the output and open the .csv file in Excel.
    What does the asymptotic complexity of insert(T thing) appear to be?
  8. Open the UnorderedListExperimentExtractMin.java class and complete it accordingly.
  9. Run the experiment to collect the output and open the .csv file in Excel.
    What does the asymptotic complexity of extractMin() appear to be?
  10. Repeat this activity with OrderedArrayExperimentInsert.java and OrderedArrayExperimentExtractMin.java.
  11. Present your results to a TA before you are signed for this studio.

Submitting your work (read carefully)



Last modified 09:46:23 CDT 22 August 2016