Menu

[solved]-Code Java Language Write Method Called Findthesecondsmallest Method Shall Take Binary Hea Q38995504

1,2,3,4 should all be in one class. Java
the code should be in Java language Write a method called findTheSecondSmallest(). The method shall take a binary heap as a pthe code should be in Java language Write a method called findTheSecondSmallest(). The method shall take a binary heap as a parameter. The method will return the second smallest element from the binary heap. 2. Write a method called findTheKthSmallest Value (). The method shall take a binary heap as a parameter and an int k, the value represents the kth smallest value interested to find in the heap. The method shall return it. Your method shall check that the kth value shall be at least available in the binary heap. In case is not, your method shall throw an IllegalArgumentException, specifying there is no such kth smallest value in the binary heap. 3. Write a method called check ForMinHeap. The method shall take a binary heap as a parameter. The method shall return true, if the given binary heap is in min-heap order, false otherwise. You can assume that the given heap is in heap order. Test the method with the following configurations • 13, 31, 100, 71, 52, 122, 101) 1/ shall return true • {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0} // shall return false • {1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 11) // shall return true 1/ shall return true • 12, 6, 4, 10, 9, 7, 5) // shall return false • 12, 6, 4, 10, 9, 1, 3) Write the method percolate Down (). The method shall take a binary heap as a parameter, and an int hole, representing the kth value desired to percolate up accordingly to the min- heap property. Show transcribed image text the code should be in Java language Write a method called findTheSecondSmallest(). The method shall take a binary heap as a parameter. The method will return the second smallest element from the binary heap. 2. Write a method called findTheKthSmallest Value (). The method shall take a binary heap as a parameter and an int k, the value represents the kth smallest value interested to find in the heap. The method shall return it. Your method shall check that the kth value shall be at least available in the binary heap. In case is not, your method shall throw an IllegalArgumentException, specifying there is no such kth smallest value in the binary heap. 3. Write a method called check ForMinHeap. The method shall take a binary heap as a parameter. The method shall return true, if the given binary heap is in min-heap order, false otherwise. You can assume that the given heap is in heap order. Test the method with the following configurations • 13, 31, 100, 71, 52, 122, 101) 1/ shall return true • {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0} // shall return false • {1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 11) // shall return true 1/ shall return true • 12, 6, 4, 10, 9, 7, 5) // shall return false • 12, 6, 4, 10, 9, 1, 3) Write the method percolate Down (). The method shall take a binary heap as a parameter, and an int hole, representing the kth value desired to percolate up accordingly to the min- heap property.

Expert Answer


Answer to the code should be in Java language Write a method called findTheSecondSmallest(). The method shall take a binary heap a… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *