Site icon Study Algorithms

The basics of Binary Trees

A tree is called a binary tree if each node has zero child, one child or two children. Empty tree is also a valid binary tree. We can visualize a binary tree as consisting of a root and two disjoint binary trees, called the left and right sub-trees of the root.

Generic Binary Tree

Types of Binary Trees

Strict Binary Tree:

A tree is called a strict binary tree if each node has exactly two children or no children.

Full Binary Tree:

A binary tree is called a full binary tree if each node has exactly two children and all leaf nodes are at the same level.

Complete Binary Tree:

Before defining the complete binary tree, let us assume that the height of the binary tree is h. In complete binary trees, if we give numbering for the nodes by starting at root (let us say the root node has 1) then we get a complete sequence from 1 to number of nodes in the tree.While traversing we should give numbering for NULL pointers also. A binary tree is called a complete binary tree if all leaf nodes are at height h or h-1 and also without any missing number in the sequence.

Properties of Binary Trees

For the following properties, let us assume that the height of the tree is h. Also, assume that root node is at height zero. From the diagram shown below we can infer the following properties.

Exit mobile version