Assignment 7 – Priority Queues ( Linked List vs. Heap implementations)

Maximum Points = 50

The purpose of this lab is to introduce you to the Priority Queue and Heap data structures and introduce analysis of algorithms. In this lab you will write a program that compares two implementations of a priority queue whose highest-priority element is the one with the smallest key value.

 

1)    The first implementation uses a minimum heap. You need to modify the heap operations to keep the minimum – rather than the maximum – element in the root.

2)    Choose for the second implementation either a linear linked list or an array, with elements that are ordered by key value.

 

Create a data set that contains n elements with priorities generated by a random-number generator where n is input by the user. To compare the implementations, you must modify the enqueue and dequeue operations to count how many elements are accessed (compared or swapped, in the case of reheaping) during its execution.

 

Write a driver to enqueue and dequeue the n test elements from the data set and display the number of elements accessed for the two operations for n.

Your driver should:

            1) enqueue all n test elements, THEN

            2) dequeue all n test elements, printing each element as it is dequeued.

 

Run your driver once with each implementation.

 

DELIVERABLES

v  A listing of specification and implementation files for both priority queue implementation

v  A listing of your driver

v  A listing of the output from runs with n= 50 and n=100 for both implementations

v  A report comparing the number of elements accessed in executing each operation and your conclusions (Word-like document)

 

 

 (Due before 5 p.m. EDT on Friday, April 30 2010) Submit your files to the Dropbox in WebCT Vista.

 Grades are determined using the following scale:

Grading Rubric  (Word document)