Let us construct the BST shown in the figure
root = Node ( 20 ) NEW_LINE root . left = Node ( 8 ) NEW_LINE root . right = Node ( 22 ) NEW_LINE root . left . left = Node ( 4 ) NEW_LINE root . left . right = Node ( 12 ) NEW_LINE root . left . right . left = Node ( 10 ) NEW_LINE root . left . right . right = Node ( 14 ) NEW_LINE n1 = 10 ; n2 = 14 NEW_LINE t = lca ( root , n1 , n2 ) NEW_LINE print " LCA ▁ of ▁ % d ▁ and ▁ % d ▁ is ▁ % d " % ( n1 , n2 , t . data ) NEW_LINE n1 = 14 ; n2 = 8 NEW_LINE t = lca ( root , n1 , n2 ) NEW_LINE print " LCA ▁ of ▁ % d ▁ and ▁ % d ▁ is ▁ % d " % ( n1 , n2 , t . data ) NEW_LINE n1 = 10 ; n2 = 22 NEW_LINE t = lca ( root , n1 , n2 ) NEW_LINE print " LCA ▁ of ▁ % d ▁ and ▁ % d ▁ is ▁ % d " % ( n1 , n2 , t . data ) NEW_LINE