boolean function ( Node arg0 , int arg1 ) { if ( arg0 == null ) { return ( arg1 == 0 ) ; } else { int loc0 = arg1 - arg0 . getKey ( ) ; return hasPathSumRecursive ( arg0 . getLeftChild ( ) , loc0 ) || hasPathSumRecursive ( arg0 . getRightChild ( ) , loc0 ) ; } }
recursive method to find the path in a tree whose sum of nodes is equal to the given number . given a tree and a sum , return true if there is a path from the root down to a leaf , such that adding up all the values along the path equals the given sum . strategy : subtract the node value from the sum when recurring down , and check to see if the sum is 0 when you run out of tree . concode_field_sep Node root concode_field_sep boolean checkSumFromRootToLeafUsingBFS concode_elem_sep boolean checkBST concode_elem_sep boolean checkBST concode_elem_sep Node constructBinaryTreeFromPreOrder concode_elem_sep Queue<Node> swap concode_elem_sep boolean checkSumFromRootToLeafUsingDFS concode_elem_sep int checkSubTreeHeight concode_elem_sep int numberOfLeavesAtLastLevel concode_elem_sep void printPaths concode_elem_sep void printPaths concode_elem_sep void main concode_elem_sep void setRoot concode_elem_sep void sendPathToConsole concode_elem_sep Node commonAncestorHelper concode_elem_sep void createBinaryTree concode_elem_sep int findMax concode_elem_sep boolean isBalanced concode_elem_sep int getHeight concode_elem_sep void inOrder concode_elem_sep Node commonAncestor concode_elem_sep void preOrder concode_elem_sep Node getRoot concode_elem_sep int findNumberOfNodes concode_elem_sep boolean covers