How To Check If a Binary Tree is Full
Here are a few practical tips
Learning how to evaluate binary trees is a useful skill for any programmer to have in their tool belt, especially a programmer looking to ace a technical interview. In this article, we’ll answer the question:
How do you check if a binary tree is a full binary tree?
To answer this question, let’s start with some definitions:
What is a full binary tree?
A full binary tree is a binary tree in which every interior node has exactly two children.
Let’s unpack it even further. First, what exactly is an interior node? Well, an interior node is a node in a tree with at least one child. And what about nodes with no children? Those nodes are considered to be leaf nodes.
Knowing these definitions, we can see that determining if a binary tree is full or not really only involves checking the interior nodes. If you were a human instead of a computer, this task would be extremely easy. You would simply look at only the nodes that aren’t leaf nodes and check if they have exactly two children.
If you’re a computer, however, you can’t simply can bounce around the binary tree with your eyes and do a quick and dirty check. Unlike with some data structures, like arrays, we…