What is a Binary Tree?
Explore the concept of binary trees in this lesson, including their definition and various types such as complete, full, and perfect binary trees. Understand the properties and structure of each type to build a solid foundation for data structures used in programming and coding interviews.
We'll cover the following...
We'll cover the following...
Introduction
A binary tree is a tree in which each node has between 0-2 children. They’re called the left and right children of the node. The figure below shows what a Binary Tree looks like.
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.
Not a complete Binary Tree
A Complete Binary Tree
Full Binary Trees
- In a full or ‘proper’ binary tree, every node has 0 or 2 children. No node can have 1 child.
- The total number of nodes in a full binary tree of height ‘h’ can be expressed as:
...