What is a Binary Tree?
Explore the fundamental concept of binary trees, where each node has up to two children. Understand the distinctions between complete, full, and perfect binary trees, including their node counting formulas. This lesson sets the foundation for comprehending more advanced tree structures used in coding and interviews.
We'll cover the following...
Introduction
A tree in which each node can have a maximum of two children is known as a binary tree. You can refer to these children as the “left” and the “right” child. 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. The total number of nodes in a complete binary tree can be expressed as:
...