The height of any rooted tree is defined as the maximum number of edges in the…

2025

The height of any rooted tree is defined as the maximum number of edges in the path from the root node to any leaf node.

Suppose a Min-Heap 𝑇 stores 32 keys. The height of 𝑇 is _____________. (Answer in integer)

Attempted by 198 students.

Show answer & explanation

Correct answer: 5

Answer: 5

Explanation: For a binary heap represented as a complete binary tree, the height h (maximum number of edges from the root to a leaf) satisfies 2^h <= n <= 2^(h+1) - 1, so h = floor(log2 n).

  • Compute floor(log2 32) = 5.

  • Alternative check: levels 0 through 4 contain 1 + 2 + 4 + 8 + 16 = 31 nodes, so the 32nd node is on level 5. Therefore the height (number of edges) is 5.

Final result: The height of the heap storing 32 keys is 5.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir