Listing 24.8, uses a heap to implement the priority queue. Revise the implementation using a sorted array

Question:

Listing 24.8, uses a heap to implement the priority  queue. Revise the implementation using a sorted array list to store the elements and name the new class PriorityQueueUsingSortedArrayList. The elements in the array list are sorted in increasing order of their priority with the last element having the highest priority. Write a test program that generates 5 million integers and enqueues them to the priority and dequeues from the queue. Use the same numbers for MyPriorityQueue and PriorityQueueUsingSortedArraList and display their execution times.

Data from Listing 24.8,

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: