Balanced Binary Tree
Prereq: DFS Fundamentals
A balanced binary tree is defined as a tree such that either it is an empty tree, or all its subtree are balanced and has a height difference of at most 1.
In that case, given a binary tree, determine if it's balanced.
tree: A binary tree.
- A boolean representing whether the tree given is balanced.
Explanation: By definition, this is a balanced binary tree.
Explanation: The subtrees of the node labelled
3 has a height difference of
it is not balanced.