Binary Tree Types
Overview
The word 'binary' is probably one of the most recognizable words in programming and in simple terms it just means - 'two things'. Or something that's created of or has two parts. Not surprisingly, 'binary' can be used in the context of trees too - Binary trees.
Binary trees are the most common main type of trees in computer science. The key property of a binary tree is that any node can only have up to 2 child nodes - no child nodes, left child, right child or left and right child nodes. It's that simple.
And these are the following main types of binary trees:
Full Binary Tree: In a full binary tree, every node can have either zero or two children. In other words, each internal node (non-leaf node) has exactly two children. Visualized as a tree where each node is either a leaf or has two subtrees.
Complete Binary Tree: The complete binary tree ensures that all levels are filled except possibly the last level. Moreover, on the last level, nodes are filled from left to right, leaving no "gaps" in the sequence of nodes.
Perfect Binary Tree: This type of binary tree is both full and complete, where all internal nodes have two children, and all levels are completely filled with nodes.
The difference between those are subtle so make sure to pay extra attention to them.
If you think that you understand the basic concept of Trees, continue with the next section to explore more about them.