CS 240: Algorithms and Data Structures
James Madison University, Spring 2019

Alternate Priority Queue Implementations

Introduction

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).

Relevant Files

Instructions

  1. First, complete TreeMinQueue.java and confirm that it works correctly using the provided unit tests.
  2. Second, take a minute to read PriorityQueueTimer.java. Consult with your partner 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.
  3. Now, double the number of elements that will be inserted into the queue. Before you re-run the tests, consider each operation to predict how the running time will be affected. Will the per-element time increase? Will it decrease? Will it stay the same? Re-run the timing code to check your predictions.

Submission

There is nothing to submit for this lab.