Yahoo Interview Question
Software Engineer / Developersrv's answer is correct. They meet at the center of the square and move on a circular trajectory. The distance from a corner to the center is therefore 1/4 of the circumference of the circle (2*pi*radius). The radius is 1/2 the length of a side of the square, L. So the distance traveled by a dog is:
1/4 * 2 * pi * 1/2 * L = pi*L/4
Since time = distance/velocity,
t = (pi*L)/(4*v)
let 'd' be the side of square and 'v' be the velocity of dogs.Now,the relative velocity of any dog w.r.t. its neighbour is {v_rel=v+vcos(90)}=>v.Hence the time taken is
d/v
correct me if wrong
Your way to look at the problem is the same as mine. And there is also another way to look a the problem. The dogs will meet at the center is for sure. So the velocity of each dog, at every moment, can be divided into two parts: the sub velocity towards the center (V_c) and the velocity perpendicular to the line between the dog and the center (V_p). |V_c| = |V_p| = |V|/sqrt(2), for each and every moment before they meet. The distance between the center and the dog was initially d/sqrt(2), so the time taken is [d/sqrt(2)] /[V/sqrt(2)] = d/V.
Consider a small time interval ∆t at the beginning of journey . In this time interval,all of them travel a distance v∆t in the direction of person they are facing.(See figure) Through this process, all persons travel along the four different quadrants of the circles with one end at their starting position and another at the center of square O.The radius of each arc is d/2 and length of arc is 1/4(2π (d/2)> = πd/4. Thus the time taken by each person moving with speed v to reach O along he quadrant arc is t= πd/(4v)
they all will meet at the center of square, and will follow a circular trajectory...
- rv September 15, 2010time = pi*L/(4*v)
where L is length of cube, and v is the speed with which dogs are running