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)
GATE 2026 CS1 Q.33: solution and answer
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)
A full binary tree requires every node to have exactly 0 or 2 children (no node has exactly 1 child).
If there are internal (2-child) nodes, the number of leaves is , so the total number of nodes is .
For : internal nodes, and leaves .
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.
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.
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.
Leaf count check: leaves from the chain (depths –) leaves from the last internal node leaves, matching .
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.
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
- GATE 2026 CS1 Q.62 · NAT · 2 marksThe following sequence corresponds to the preorder traversal of a binary search tree T: 50, 25, 13, 40, 30…
- GATE 2026 CS2 Q.12 · MCQ · 1 markThe set T represents various traversals over binary tree. The set S represents the order of visiting nodes…
- GATE 2026 CS2 Q.49 · MSQ · 2 marksConsider a binary search tree (BST) with n leaf nodes (n > 0). Given any node V, the key present in the node…
- GATE 2026 DA Q.25 · MSQ · 1 markYou are given the following Pre-order and In-order traversals of a Binary Tree T with nodes E, F, G, P, Q…
