@Ravi : yeah dere is..and it was discussed before on this group.. check out this link :- check soln by Lucifier..
http://groups.google.com/group/algogeeks/browse_thread/thread/9bbdd33a6b1e1c5f/fab5d6ad3840b74d?hl=en&lnk=gst&q=Find+the+path+in+two+nodes+of+a+binary+search+tree#fab5d6ad3840b74d On Thu, Mar 1, 2012 at 9:18 PM, Ravi Ranjan <[email protected]> wrote: > @atul > > two nodes were given in the qstn....... > > i did > > 1) calculate the level of one node through level order traversal similarly > for other > 2) then find the Least Common Anscestor > 3) then dist(LCS - node1) + dist(LCS - node2) > > but i think this was not optimized bcse he was not very much satisfied by > this > > So if any of you know some bettr approach then please tell > > thanks a lot :) > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
