Tree Height
An interactive, step-by-step visualisation of Tree Height.
- Category
- Trees
- Time complexity
- O(n)
- Space complexity
- O(h)
Pseudocode
height(t): if not t: return -1 return 1 + max(height(t.left), height(t.right))
Reference implementation
def height(t):
if not t: return -1
return 1 + max(height(t.l), height(t.r))