# Category: Binary Tree

Binary Trees

## Check if a Binary Tree is Symmetric or not

Given a binary tree, write an efficient algorithm to check if it is symmetric binary tree or not. i.e. left subtree and right subtree are mirror images or each other.   Get great deals at Amazon

## Find Diameter of a Binary Tree

Given a binary tree, write an efficient algorithm to compute the diameter of it. The diameter of a binary tree is equal to number of nodes on the longest path between any two leaves in it.

## Determine if given binary tree is a subtree of another binary tree or not

Given a binary tree, determine if it is a subtree of another binary tree or not. A subtree of a tree T is a tree consisting of a node in T and all of its descendants in T.

## Combinations of words formed by replacing given numbers with corresponding alphabets

Given a set of positive numbers, find all possible combinations of words formed by replacing the continuous digits with corresponding character of English alphabet. i.e. subset {1} can be replaced by A, {2} can be replaced by B, {1, 0} can be replaced J, {2, 1} can be replaced U, etc..

## Check if given binary tree is a sum tree or not

Given a binary tree, check if it is a sum tree or not. In a sum tree, value at each non-leaf node is equal to the sum of all elements present in its left and right subtree. The value of a leaf node can be anything.

## In-place convert given binary tree to its sum tree

Given a binary tree, in-place convert it to its sum tree. In a sum tree, value at each node is equal to the sum of all elements present in its left and right subtree. The value of an empty node is considered as 0.

## Print cousins of given node in a binary tree

Given a binary tree, print all cousins of a given node. Two nodes of binary tree are cousins of each other only if they have different parents but they have same level.

## Determine if given two nodes are cousins of each other

Given a binary tree, determine if two given nodes are cousins of each other or not. Two nodes of binary tree are cousins of each other only if they have different parents but they have same level.

## Check if given binary tree is complete binary tree or not

Given a binary tree, check if it is a complete binary tree or not.

## Find next node in same level for given node in a binary tree

Given a binary tree and a node in it, write an efficient algorithm to find its next node in same level as given node.

## Print Top View of Binary Tree

Given an binary tree, print top view of it. Assume, the left and right child of a node makes 45 degree angle with the parent.

## Print Bottom View of Binary Tree

Given an binary tree, print bottom view of it. Assume, the left and right child of a node makes 45 degree angle with the parent.