1) how do find out if there is a path from root to leaf whose summation= given number?
Sigiloso
Here is my solution, please do let me know if it works. class Node{ public int value; public Node left; public Node right; } boolean function pathExists(Node node, int givenNumber){ //first case, if the node is null, conclude false if( node == null ){ return false; } //if reach leave if( node.left == null && node.right == null){ //decision bases on the remaining and the leaf's value return (node.value == givenNumber ); } //keep searching the remaining in node's children return pathExists(node.left, givenNumber - node.value) || pathExists(node.right, givenNumber - node.value); }