Question

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 TT stores 32 keys. The height of TT is _____________. (Answer in integer)

Official answer and solution
Official answer
5
From
Official GATE 2025 answer key

Solution

Use the height formula h=⌊log⁡2n⌋h = \lfloor \log_2 n \rfloor for a complete binary tree with nn nodes.

A binary Min-Heap with nn keys is stored as a complete binary tree of nn nodes. The height (maximum number of edges from the root to a leaf) of a complete binary tree with n=32n = 32 nodes is:

h=⌊log⁡232⌋=5h = \lfloor \log_2 32 \rfloor = 5
Final answer

5

Common trap

Counting the number of levels (6) instead of the number of edges (5).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
35 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.