Write a program in Java to implement the max-priority queue using max-heap data structure. Implement the max-heap data structure using an integer array of 10 cells. (Do not use Java in-built PriorityQueue class.) [In a max-heap, the root node and the intermediate node vales are always greater than their children.] First, take 10 integer values from the user and insert them in the max-priority queue. Then print the elements of the queue. After that, delete two elements from the queue and print them. You can use Java Scanner class to take inputs from the user.
The sample inputs/ outputs are given below:
Sample inputs and outputs: (User’s inputs are 5 15 9 7 20 18 8 6 1 11)
Enter 10 values: 5 15 9 7 20 18 8 6 1 11
The elements of the max-priority queue: 20 15 18 6 11 9 8 5 1 7
The element removed after first deletion: 20
The element removed after second deletion: 18
Hello
I can start working on this assignment right away and get it implemented in the next 4 to 6 hours. Let me know if you are interested.
Thanks
Gokul
Hello,
I am a Java developer experienced in implementing such structures & algorithms.
I can build the max-heap as required and provide proper documentation.
Past project:
- Java queue in simulation & modeling
Kindly reply via chat.