Implement the priority queue structure using the Heap class in the lecture.

computer science

Description

Homework 3:

Due 11/13 (Wednesday)

1.      Implement the priority queue structure using the Heap class in the lecture.

2.      Create a class, PrintJob, to simulate print jobs with the following attributes:

serialNumber: a unique number in order when a print job is created.

numPages: the number of pages of the print job.

3.      Create the main class, HeapDemo, to test the Heap and PrintJob calsses where a print job has higher priority if it has fewer pages. The following are the tasks:

a.      Create 10 print jobs.

b.      Add them in an empty priority queue, called printJobHeap.

c.       Display the heap.

d.      Create 1000 print jobs, then add them into a new  empty priority queue, called biggerPrintJobHeap. Use random numbers to determine the number of pages of a print job, with the maximal number of pages 300. 

e.      Display the heap.

f.        Create 1,000,000 print jobs, then add them into a new empty priority queue, called muchBiggerPrintJobHeap, with the same requirements on the maximal number of pages. 

Display the heap.


Related Questions in computer science category