Lowest common ancestor

what if one value is not present in tree…let me know what will be the change in code for satisfying this condition

Hey,then lca will be undefined or you can return root.
To handle that case what you can do is find the nodes first ,if you can’t find any of the given node then return root or Null, whatever is given in problem.
For the case when both nodes are present,just run normal lca