(Min-heap) The heap presented in the text is also known as a max-heap, in which each node is greater than or equal to any of its children. A min-heap is a heap in which each node is less than or equal to any of its children. Min-heaps are often used to implement priority queues. Revise the Heap class in Listing 23.9 to implement a min-heap. Use the following main method to test your implementation. public static void main(String[] args) { /** test with Integers */ Integer[]myIntegers={8, 9, 2, 3, 4, 1, 5, 6, 7}; System.out.println("Unsorted Integers in the array: "); for (int i = 0; i
(Min-heap) The heap presented in the text is also known as a max-heap, in which each node is greater than or equal to any of its children. A min-heap is a heap in which each node is less than or equal to any of its children. Min-heaps are often used to implement priority queues. Revise the Heap class in Listing 23.9 to implement a min-heap. Use the following main method to test your implementation. public static void main(String[] args) { /** test with Integers */ Integer[]myIntegers={8, 9, 2, 3, 4, 1, 5, 6, 7}; System.out.println("Unsorted Integers in the array: "); for (int i = 0; i <myIntegers.length; i++) System.out.print(myIntegers[i] + " "); System.out.println();

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images









