Distance between 2 nodes in a binary tree

How can i find distance between 2 nodes in a binary tree

The simplest thing that comes to my mind is that you find the Lowest common ancestor of the 2 nodes which is a pretty standard question.The answer is simply the sum of the distance of each node from this ancestor. By distance i am assuming you mean the shortest path between the 2 nodes in a binary search tree.

1 Like

thanks, got it

//