find ancestor of two nodes in a binary tree algorithm : - check if both p and q are on different sides of a node then that node is the ancestor - else go to left subtree or right subtree time complexity : o n 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 boolean hasPathSumRecursive concode_elem_sep void inOrder concode_elem_sep void preOrder concode_elem_sep Node getRoot concode_elem_sep int findNumberOfNodes concode_elem_sep boolean covers
Node function ( Node arg0 , Node arg1 , Node arg2 ) { if ( ( ! covers ( arg0 , arg1 ) ) || ( ! covers ( arg0 , arg2 ) ) ) { return null ; } return commonAncestorHelper ( arg0 , arg1 , arg2 ) ; }