Height of a tree with only one node

It just an assuption you make for the recursive description of the height of a binary tree. You can consider a tree composed by just a node either with 0 height or with 1 height.

If you really want to think about it somehow you can think that

  • it’s 0 if you consider the height as a edge count (so that a single node doesn’t have any edge, hence 0)
  • it’s 1 if you consider the height as a node count (so that a single node counts as 1)

This is just to describe how much height the smallest tree has, then in any case whenever you add a descending node you will add also a related edge so it will increase accordingly.

In the example provided in wikipedia:

alt text

This tree can have height 4 (nodes) or 3 (edges). It depends if you are counting it by edges or by nodes.

Leave a Comment

tech