You are viewing a single comment's thread. Return to all comments →
PYTHON 3
Tail recursive causes unnecessary backlash. Use iterative approach.
def lca(root, v1, v2): while True: if root.info>v1 and root.info>v2: root=root.left elif root.info<v1 and root.info<v2: root=root.right else: return root
Binary Search Tree : Lowest Common Ancestor
You are viewing a single comment's thread. Return to all comments →
PYTHON 3
Tail recursive causes unnecessary backlash. Use iterative approach.