After 1st removal (Answer stored in output[0]) After 2nd removal (Answer stored in output[1]) After 3rd removal (Answer stored in output[2]) After 4th removal (Answer stored in output[3]) After 5th removal (Answer stored in output[4])
After 1st removal (Answer stored in output[0]) After 2nd removal (Answer stored in output[1]) After 3rd removal (Answer stored in output[2]) After 4th removal (Answer stored in output[3]) After 5th removal (Answer stored in output[4])
Related questions
Question
- Remove the top element 5 times from the given binary min-heap and draw the tree representations of the initial heap and the heap after each removal. Then, for each iteration of removal, convert your tree representation into array representation. Store the values into the method removalResult.
Array representation of the initial heap:
[30, 56, 37, 59, 62, 42, 50, 67, 70, 75, 64, 90]
Note: Within Worksheet.java, you’re given an empty 5-by-12 2D array output. For row i, you’ll be storing the array representation of the i+1th removal. If the number of elements within the heap is less than 12 elements, then you pad it with 0’s at the back.
E.g.: If the array representation after 1st removal is
[46, 39, 100, 93, 96, 101, 64, 20, 34, 30, 91],
then
output[0] = [46, 39, 100, 93, 96, 101, 64, 20, 34, 30, 91,0]
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps