Microsoft Interview Question
Program ManagersYou fool, why won't trains travelling in opposite directions not collide according to the given question.
N plz apply common sense before writing "can never collide".
Everybody know how to find the distance traveled by the bird. The attraction of the question is the second part... The answer will surprise you..... It depends on the size of the bird (If its a point then infinite, if it is not a point then why are we even solving such a puzzle :). BTW for the trains never colliding read: en.wikipedia.org/wiki/Zeno%27s_paradoxes
distance traveled: D/vb, where D is the initial distance and vb is the speed of the bird;
Time U turned: infinite. Suppose finite, at the last U turn, suppose the trains are d apart, in d/(vt + vb) time, the bird run into the other train, however the trains are still d(1 - 2vt/(vt + vb))>0 apart, which means there is another U turn. contradiction
if the time of collision of two trains is finite, how can the number of U turns be infinite??
D: distance between 2 trains
- zglgjg May 10, 2010v1,v2: speeds of two trains
v3: speed of bird(v3>v1 &&v3>v2)
1)Find the time taken to collide
T1=D/(v1+v2)
2)total distance traveled by the bird
D2=T1*v3
3)# of times bird makes a U turn
Maybe infinite (not sure)