Question:

Given the index i of a node in a heap, we can not compute:

Show Hint

In a heap, the parent and children indices are easily computed, but the heap size requires separate tracking.
Updated On: Sep 25, 2025
  • Parent(i)
  • Heap size
  • Left(i)
  • Right(i)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation


 

Step 1: Understanding Heap Properties. 
- **Parent(i)**: We can compute the parent of node \( i \) using the formula \( \text{parent}(i) = \frac{i-1}{2} \), which gives the index of the parent node in a binary heap. 

- **Left(i)**: We can compute the left child of node \( i \) using the formula \( \text{left}(i) = 2i + 1 \). 

- **Right(i)**: We can compute the right child of node \( i \) using the formula \( \text{right}(i) = 2i + 2 \).

Step 2: Heap Size. 
We cannot compute the heap size directly from the index of a node. The heap size is generally known from external information or passed along with the heap structure. 
 

Step 3: Conclusion. 
Thus, the correct answer is **(2) Heap size**. 
 

Was this answer helpful?
0
0

Questions Asked in CUET PG exam

View More Questions