博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
赛马题(转)
阅读量:4606 次
发布时间:2019-06-09

本文共 1864 字,大约阅读时间需要 6 分钟。

转自: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

转载于:https://www.cnblogs.com/springfor/p/4044821.html

你可能感兴趣的文章
努力,时间,坚持,自律
查看>>
Hadoop2.6.0 动态增加节点
查看>>
图论的一些概念、定理
查看>>
WebView用法
查看>>
Lecture 3: Planning by Dynamic Programming
查看>>
用flash代替图片IMG,设置动态效果链接
查看>>
关于JS的随笔(二)
查看>>
select()函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET(转)
查看>>
webbug3.0菜鸟笔记1
查看>>
数组相关函数
查看>>
Python 和其他编程语言数据类型的比较
查看>>
T2695 桶哥的问题——送桶 题解
查看>>
HTML5 表单
查看>>
Android群英传》读书笔记 (3) 第六章 Android绘图机制与处理技巧 + 第七章 Android动画机制与使用技巧...
查看>>
关于微信公众平台测试号配置失败的问题
查看>>
【NOIP2001】统计单词个数
查看>>
linux常用端口
查看>>
异常处理
查看>>
/proc/uptime详解
查看>>
如何建立合适的索引?
查看>>