Level and Height of the tree

Rumman Ansari   Software Engineer   2023-03-27   9930 Share
☰ Table of Contents

Table of Content:


Level can be represent in two ways

  1. Level start with 0 from root nodebinary tree
  2. Level start with 1 from root node binary tree

Level start with 0 from root node

The maximum number of nodes on level i of a binary tree is 2i , i>=0

binary tree

Level start with 1 from root node

The maximum number of nodes on level i of a binary tree is 2i-1 , i>=1

binary tree

Depth can be represent in two ways

  1. Depth start with 0 from root node binary tree
  2. Depth start with 1 from root node binary tree

Depth start with 0 from root node

The maximum number of nodes in a binary tree of depth k is 2(k+1) - 1 where k >= 0

binary tree depth of the tree

Depth start with 1 from root node

The maximum number of nodes in a binary tree of depth k is 2k-1 where k >= 0

binary tree depth of the tree

Height Example

  1. Height start with 0 from root node binary tree height of the tree