Given A binary Tree, how do you remove all the half nodes (which has only one child)? Note leaves should not be touched as they… Read More »
A complete binary tree is a binary tree whose all levels except the last level are completely filled and all the leaves in the last… Read More »
A full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no… Read More »
Given a Binary Tree, find sum of all left leaves in it. For example, sum of all left leaves in below Binary Tree is 5+23+50… Read More »
Given a Binary Tree and a number k, remove all nodes that lie only on root to leaf path(s) of length smaller than k.
Given a Binary Tree and a key ‘k’, find distance of the closest leaf from ‘k’.
Consider lines of slope -1 passing between nodes (dotted lines in below diagram). Diagonal sum in a binary tree is sum of all node’s data… Read More »
Given a Binary Tree, we need to print the bottom view from left to right.
Given a Perfect Binary Tree like below: (click on image to get a clear view)
Top view of a binary tree is the set of nodes visible when the tree is viewed from the top. Given a binary tree, print… Read More »
We have discussed Threaded Binary Tree. The idea of threaded binary trees is to make inorder traversal faster and do it without stack and without… Read More »
Given an N-ary tree where every node has at-most N children. How to serialize and deserialze it? Serialization is to store tree in a file… Read More »
Serialization is to store tree in a file so that it can be later restored. The structure of tree must be maintained.
Write a function that returns true if a given undirected graph is tree and false otherwise. For example, the following graph is a tree.
Given a binary tree and two level numbers ‘low’ and ‘high’, print nodes from level low to level high.