The half-full node
A complete binary tree has every level full except possibly the last, which is filled left-to-right. Stored in a -indexed array of nodes (node has children at and ), how many of its nodes have exactly one child (as opposed to two children or none)?
Show hints (2)+
- A one-child node needs its left-child index in range but its right-child index out of range: .
- That equation has an integer solution only when is even - how many solutions, and is even?
Answer
Reveal answer →Final answer
1
Create a free account to see the full worked solution and track your progress.
Interview format: Hedge Fund Quant, Prop Trading