First, you are to time the performance of the each
of the priority queues under repeated insertion
and extraction operations. The PriorityQueue class
has a demo class method that will
be inherited by each class which inherits from PriorityQueue.
This demo creates an instance of the class it was called
on (by calling self new within the class
method). It then repeatedly inserts N random numbers
in the queue (and prints them to the trascript), and
then repeatedly extracts N numbers from the queue
(and prints them to the transcript). N is an integer
argument passed to the demo method. Note that by
repeatedly extracting the minimum value you are in fact
sorting the numbers and you should notice this from
the transcript. Run the following two examples and
look at the transcript.
PriorityQueueOC demo: 10 "sort 10 random numbers"and then
PriorityQueueOC demo: 40 "sort 40 random numbers"