Category: Binary Tree

Binary Trees

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 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.