## Microsoft Interview Question Program Managers

• 0

puzzle - 2 trains traveling in opposite direction, bird starts from one and reaches other and flies back and forth like this till train collide. Find the time taken to collide, total distance traveled by the bird, and no. of times bird makes a U turn.

Comment hidden because of low score. Click to expand.
0
of 0 vote

D: distance between 2 trains
v1,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)

Comment hidden because of low score. Click to expand.
0
of 0 vote

hey i also think so

Comment hidden because of low score. Click to expand.
0
of 0 vote

trains traveling in opposite directions never collide

Comment hidden because of low score. Click to expand.
0

You 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".

Comment hidden because of low score. Click to expand.
0

First of all trains will never travel on the same track in opposite directions.

Comment hidden because of low score. Click to expand.
0

Obviously you don't know much about how trains travel in China.

Comment hidden because of low score. Click to expand.
0
of 0 vote

trains traveling in opposite directions never collide

Comment hidden because of low score. Click to expand.
0
of 0 vote

Train travelling in opposite direction may collide, train travelling in same direction may collide.. only one train can also collide with itself.. ask Indian Railway..
what about the poor bird.. its not even afraid of train whistle..it should die before the last three U turns. :)

Comment hidden because of low score. Click to expand.
0
of 0 vote

u all are bastards

Comment hidden because of low score. Click to expand.
0
of 0 vote

zglgjg is right.
No. of u turns is indefinite,the problem can be identified when there is too short a distance between the trains ie when they are about to collide.

Comment hidden because of low score. Click to expand.
0
of 0 vote

what is the answer for the second part i.e number of trips made by bird? there will be a infinite series right ..but what is it?

Comment hidden because of low score. Click to expand.
0
of 0 vote

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

Comment hidden because of low score. Click to expand.
0
of 0 vote

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

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book walking you through every aspect of getting a job at a top tech company, while focuses on software engineering interviews.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.