You are viewing a single comment's thread. Return to all comments →
class Node: def init(self,info): self.info = info self.left = None self.right = None
// this is a node of the tree , which contains info as data, left , right
'''
def lca(root, v1, v2): node=root if node is None: return None if node.info>v1 and node.info>v2: return lca(node.left,v1,v2) elif node.info
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 →
class Node: def init(self,info): self.info = info
self.left = None
self.right = None
'''
def lca(root, v1, v2): node=root if node is None: return None if node.info>v1 and node.info>v2: return lca(node.left,v1,v2) elif node.info