赛马题(转)

转自:http://intearview.com/post/2010/04/04/Ranganathgs-interview-at-google-company.aspx 

 

You have 15 horses that run various speeds. You own a race track on which you can race the horses, and this track holds a maximum of 5 horses per race. If you have no stopwatch or other means of telling exactly how fast the horses are, how many races would you need to run between the horses to be ABSOLUTELY SURE which horses are first, second, and third fastest?


My Answer
Race 1: Horse 1,2,3,4,5 => Assume 1,2,3 win in that order
Race 2: Horse 6,7,8,9,10 => Assume 6,7,8 win in that order
Race 3: Horse 11,12,13,14,15 =>Assume 11,12,13 win in that order

Race 4: Horse 1, 6, 11 (all first place winners) =>Assume 1 wins first (1 is the fastest) for the sake of simplicity and 6 and 11 came 2nd and 3rd place
Race 5: Horse 6, 11, 2, 7, 3 - Notice I did not choose horse 12 in this race because we assumed from Race 4 that horse 11 came in third place so it is of no value having horse 12 in the race.

Total Race 5
1st Place is Horse 1, 2nd and 3rd Place is found from Race 5

5) Follow up, now you have 16 horses. How many races would you need to conduct to find first, second, and third?

My Answer
First three races are identical to the above three races

Assumption 1:
Race 4: Horse 16, 1, 6, 11 => Assume 16 wins first, and Horse 1 and 6 came second and third.
Race 5: Horse 1, 6, 2, 7, 3 =>Notice I did not choose any horses from Race 3 results, this is because we know that horse 11 did not come out in the top 3 in Race 4.

Total Race 5

Assumption 2:
Race 4: Horse 16, 1, 6, 11 => Assume 1 wins first, and Horse 6 and 16 came second and third.
Race 5: Horse 6, 16, 2, 7, 3=>Notice I did not choose any horses from Race 3 results, this is because we know that horse 11 did not come out in the top 3 in Race 4.

Total Race 5
posted @ 2014-10-23 04:01  爱做饭的小莹子  阅读(734)  评论(0编辑  收藏  举报