LOWEST COMMON ANCESTOR IN BST
PROBLEM => FIND THE LOWEST COMMON ANCESTOR OF TWO NODES (a & b) IN BINARY SEARCH TREE STEPS => 1.Find whether these two nodes are present in bst.If not found then return NULL. 2.If both nodes are found then there are 4 possibilites => 1.root == a || root == b => return root 2.a is found in left subtree and b is found in right subtree => return NULL from that subtree where we cant find both a & b 3.if a and b are found in left/right subtree return root node * lca...
Comments
Post a Comment