Maximum Nodes in a Binary Tree of Bounded Depth
Coding
Trees
Easy
Hint 1
Count the maximum number of nodes possible at each depth level from 0 to d.
Hint 2
Level can hold at most nodes; sum a geometric series.
Show worked solution
1. Count nodes level by level
A binary tree can have at most nodes at depth , for .
2. Sum the geometric series
Summing over all levels gives a geometric series that telescopes to a closed form.
Answer: 2^(d+1)-1
Related roles: Browse quant jobs