Question: Must be in JAVA. 1. Design and implement a Binary Heap class that must support insert and deleteMin operations. 2. Design and implement a driver
Must be in JAVA.
1. Design and implement a Binary Heap class that must support "insert"
and "deleteMin" operations.
2. Design and implement a driver (the main method) that does the following:
(a) Creates an array that contains a list of 4099 integers, in a random
order, between 0 to to 4098.
(b) insert, into the rst binary heap that is initially empty, the numbers
in the array sequentially from the start to the end.
(c) Initialize the second empty binary heap.
(d) Enter a forever while loop to do the following:
i. Collect the rst timestamp.
ii. Call "deleteMin" to remove the smallest value from the rst heap,
and display "The process with a priority of %d is now scheduled
to run!"
iii. For the removed value, change it to a random value between 0
and 4098.
iv. Call "Insert" to insert the removed value (now changed to a
dierent value in the previous step) to the second heap, and
display "The process with a priority of %d has run out of its
timeslice!"
v. When the rst heap becomes empty, collect the second times-
tamp, compute the of the two timestamps, and display "It
took msecs for all processes to run out of their timeslices.";
Please press "Enter" to start the next round!"
vi. When "Enter" is pressed, swap the two heaps, and continue the
loop.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
