Complete the code to identify the root element in a max-heap.
root = heap[[1]]In a max-heap stored as an array, the root element is always at index 0.
Complete the formula to find the left child index of a node at index i in a heap.
left_child_index = 2 * [1] + 1
The left child of a node at index i in a zero-based heap array is at index 2*i + 1.
Fix the error in the code to get the parent index of a node at index i in a heap.
parent_index = ([1] - 1) // 2
The parent of a node at index i is at (i - 1) // 2 in a zero-based heap array.
Fill both blanks to create a dictionary comprehension that maps each node to its depth in a heap of size n.
{node: [1] for node in range(n) if node [2] n}The depth of a node in a heap can be found using the bit length of its index minus one. The comprehension includes nodes with index less than n.
Fill all three blanks to create a dictionary comprehension that maps each node to its parent index in a heap of size n, excluding the root.
{node: ([1] - 1) // 2 for node in range(1, [2]) if node [3] n}This comprehension calculates the parent index for each node from 1 up to n, excluding the root at index 0. The condition ensures nodes are less than n.