You are viewing a single comment's thread. Return to all comments →
python code:
def lca(root, v1, v2):
if root.info > v1 and root.info > v2:
return lca(root.left,v1,v2)
elif root.info < v1 and root.info < v2:
return lca(root.right,v1,v2)
else: 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 →
python code:
def lca(root, v1, v2):
if root.info > v1 and root.info > v2:
elif root.info < v1 and root.info < v2:
else: return root