IAE Academy

GATE 2026 CS1 Q.33: solution and answer

GATE 2026 · CS1Q.33 · 1 mark · NAT

The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible height of a full binary tree with 23 nodes is __________. (answer in integer)

See the question in the paper

Answer and solution

ANSWER

The maximum possible height of a full binary tree with 23 nodes is 11.

Official answer: 11Source: Official answer key, GATE 2026 CS1 (IIT Guwahati)

  1. A full binary tree requires every node to have exactly 0 or 2 children (no node has exactly 1 child).

  2. If there are internal (2-child) nodes, the number of leaves is , so the total number of nodes is .

  3. For : internal nodes, and leaves .

  4. To maximise height, make the tree as skewed as possible: chain the internal nodes down one side of the tree, so each internal node (except the last one in the chain) has one leaf child and one child that continues the chain.

  5. Place the 11 internal nodes at depths . The internal nodes at depths through each spawn one leaf child (using 10 leaves) and one child continuing the chain to the next depth.

  6. The internal node at depth 10 is the last internal node in the chain — it cannot continue the chain (that would require a 12th internal node, leaving too few nodes to keep ), so both of its children are leaves, at depth 11.

  7. Leaf count check: leaves from the chain (depths –) leaves from the last internal node leaves, matching .

  8. The longest root-to-leaf path passes through all 11 internal nodes (depths to ) and ends at a leaf at depth 11, i.e. it has 11 edges.

  9. So the maximum possible height is , consistent with the general result for a full binary tree with nodes.

KEY IDEA

In a full binary tree (every node has 0 or 2 children) with internal nodes, leaves , so ; to maximise height, chain the internal nodes into a single skewed path, giving one leaf off each internal node except the last (which contributes two leaves), so height.

WATCH OUT FOR

Confusing "full" binary tree (every node has 0 or 2 children — degenerate/skewed shapes are still allowed as long as no node has exactly one child) with "complete" or "perfect" binary tree, and instead computing the height of a perfect/complete tree with 23 nodes (which gives a much smaller height, around ), or forgetting that the last internal node in the skewed chain must take two leaf children (not one), which would misalign the leaf count.

From the GATE 2026 CS1 paper. Every question of this paper · Download the full paper · All 26 Trees & heaps questions, with notes

More Trees & heaps questions