Complete the code to identify the root element in a max-heap.
root = heap[[1]]The root element of a max-heap is always at index 0 in the array representation.
Complete the code to find the left child index of a node at index i in a heap.
left_child = 2 * i [1] 1
In a heap, the left child of node at index i is at 2*i + 1.
Fix the error in the condition to check if the right child exists in the heap array.
if right_child_index [1] len(heap):
The right child exists only if its index is less than the length of the heap array.
Fill both blanks to correctly swap the parent with the larger child during bubble down.
if heap[[1]] < heap[[2]]: heap[[1]], heap[[2]] = heap[[2]], heap[[1]]
During bubble down, the parent is swapped with the larger child, here the right child index is used.
Fill all three blanks to complete the bubble down step choosing the larger child correctly.
larger_child = [1] if heap[[2]] > heap[[3]] else [3]
This line selects the larger child index by comparing left and right child values.