Question: An array A=[42, 20,17,13, 28, 14, 23, 15, 36, 54, 75, 93, 5, 101] is input to build a MaxHeap tree. Once the MaxHeap is
An array A=[42, 20,17,13, 28, 14, 23, 15, 36, 54, 75, 93, 5, 101] is input to build a MaxHeap tree. Once the MaxHeap is built, the removemax() function is invoked. After the first time removemax() is invoked, what is the value at the root?

/** Remove and return maximum value */ public E removemax() { assert n > "Removing from empty heap"; DSutil.swap(Heap, 0, --n); // Swap maximum with last value // Not on last element if (n != 0) siftdown(0); return Heap[n]; // Put new heap root val in correct place }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
