You are viewing a single comment's thread. Return to all comments →
def lca(root, v1, v2): while(root != None): if(v1 > root.info and v2 > root.info): root = root.right elif(v1 < root.info and v2 < root.info): root = root.left else: break return root
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Lowest Common Ancestor
You are viewing a single comment's thread. Return to all comments →
O(height) python solution: