Search code examples
data-structurestreecomputer-sciencebinary-treediscrete-mathematics

How to find minimum height of a binary tree, if you know its numbers of nodes?


Let n be the number of nodes of a binary tree, then what will be the general functional term to find out the minimum height of the binary tree?

I think it will be n=floor(log2(n))+1. But, I think, I'm wrong.


Solution

  • From Binary Tree Height:

    If you have N elements, the minimum height of a binary tree will be log2(N)+1.