Path Sum (Binary Tree Root to Leaf Path Sum)

Binary Tree Root to Leaf Path Sum Equal to a Given Number.

Given a binary tree and a sum, Determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.

If path is found then return true else return false.

Note: What is leaf node? Any node whose left and right children is null is known as leaf node.

For example –

In this Binary tree, there exist a path from root-to-leaf node whose sum is equal to the given sum (which is 16).

Now, suppose if the given value of sum is 12. Then in this case we simply return false. As the root-to-leaf node path does not exist in a Binary tree whose sum is equal to 12.

Reverse Level Order Traversal of a Binary Tree

Given a binary tree, write a code to print its reverse level order traversal.

For example:

The reverse or bottom-up level order traversal of this binary tree is 4, 3, 2, 1, 6, 5, 7.

In this example, first we printed last level then second last level and so on. So, we have to start printing the level from bottom-up.