Given a binary tree and 2 nodes , find the least common ancestor.
( assume that both the nodes are present in the given tree )
Other Variants:
1. What if the binary tree is a binary search tree ?
2. What if the assumption, regarding the presence of both the nodes (whose LCA is to be found), is removed ? How would the code change in case of a binary tree as well as a binary search tree ?
( assume that both the nodes are present in the given tree )
Other Variants:
1. What if the binary tree is a binary search tree ?
2. What if the assumption, regarding the presence of both the nodes (whose LCA is to be found), is removed ? How would the code change in case of a binary tree as well as a binary search tree ?