A complete binary tree has 31 nodes. What is its height? (Root at height 0)
A complete binary tree has 31 nodes. What is its height? (Root at height 0)
Answer
4
Theory
A complete binary tree with n nodes has height ⌊log₂n⌋.
Solution
⌊log₂31⌋ = 4.