What is a Binary Tree?

An introduction to binary trees and different types of binary trees.

Introduction

A tree in which each node can have a maximum of two children is known as a binary tree. We can refer to these children as the left and the right child. The figure below shows what a Binary Tree looks like :

%0 1 1 2 2 1->2 3 3 1->3 4 4 2->4 null 5 2->null

Types of Binary Trees

Complete Binary Trees

A complete binary tree is a binary tree in which all the levels of the tree are fully filled, except for perhaps the last level, which can be filled from left to right. The total number of nodes in a complete binary tree can be expressed as:

2htotal number of nodes2(h+1)12^{h} \leq \text{total number of nodes} \leq 2^{(h+1)}-1 ...

Access this course and 1400+ top-rated courses and projects.