What is the height of a complete binary tree with N nodes? I'm looking for an exact answer, and either a floor or ceiling value.
It's CEIL(log2(n+1))-1
EDIT: According to wikipedia, the root node (rather un-intuitively?) does not count in the height, so the formula would be CEIL(log2(n+1))-1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With