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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
27 | 28 | 29 | 30 | 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |