[algogeeks] Re: Yahoo Interview Question for Software Engineer/Developer about Algorithms

2010-09-18 Thread soundar
Even if u are connected to that person via some another friend it'll show the shortest chain by which you are connected to that person..So DFS will be optimum i guessWhy do you think it wouldn't be optimum.? -- You received this message because you are subscribed to the Google

Re: [algogeeks] Re: Yahoo Interview Question for Software Engineer/Developer about Algorithms

2010-09-18 Thread Shiv ...
i will choose BFS. As we just don't want to show a connection.. we want to show the shortest one. On Sat, Sep 18, 2010 at 4:12 PM, soundar soundha...@gmail.com wrote: Even if u are connected to that person via some another friend it'll show the shortest chain by which you are connected to that

[algogeeks] Re: Yahoo Interview Question for Software Engineer/Developer about Algorithms

2010-09-18 Thread Gene
You could construct two level graphs starting starting simultanously from your node and the other member's. Add layers one at a time to each. When, after adding a new level, you find one or more nodes in both level graphs, you can stop. Each shared node gives you a least-edge path between the