Algorithm Deep Dive Computer Science

Basic Problems and Solutions Involving Binary Trees

In this section we will go through some of the basic programming problems involving binary trees.

Finding height of a binary tree

The height of a binary tree is the length of the longest path from the root node to the deepest leaf node in the tree. It is also defined as the number of edges in the longest path from the root node to any leaf node in the tree. Generally

Check if a value exists in a Binary Tree

We can perform any tree traversal technique like in-order, pre-order, post-order etc and check if the element is present while each node is visited. But of all traversals, pre-order traversal is more efficient as we skip traversing all the