0

what is the height of avl tree with n nodes ? Can you explain it with formula ? I couldn't find any formula to solve this problem.

ozdemir
  • 11
  • 1

1 Answers1

1

AVL trees are self-balancing binary search trees (another example is red-black trees). By definition, a self-balancing binary tree maintains the property that its height is $\Theta(\log n)$, where $n$ is the number of leaves or vertices (the two properties corresponding to the two different definitions of $n$ are equivalent).

Usually it is costly to have a data-independent height, and so the height depends on the history of the data structure (it depends on the exact order in which values were inserted and deleted), but it is always $O(\log n)$. (Note that every binary tree has height $\Omega(\log n)$.)

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514