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

本文共 1811 字,大约阅读时间需要 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

转载地址:http://imzml.baihongyu.com/

你可能感兴趣的文章
初识btrace
查看>>
Mybatis-plus之RowBounds实现分页查询
查看>>
AjaxPro.Net的使用
查看>>
分享一些经典资源
查看>>
HDU-1723 Distribute Message
查看>>
6200 sdboot 测试版分析(一)
查看>>
WayOs扩展WAN口工具1.4隆重发布,同时发布BCM内置三天智能重启超级终端调试图...
查看>>
Java反编译插件Jdclipse导致Eclipse 3.7.2启动崩溃的解决方法
查看>>
关于Installshield中Ie8\Ie9\SQL Server 2008 R2 Native Client等Prq文件在线下载地址
查看>>
SQL Server 2008中增强的汇总技巧
查看>>
they're hiring
查看>>
几个 HTML 标签的用法
查看>>
《老罗Android开发视频教程-安卓巴士》(Android 开发)
查看>>
asp.net 伪静态 IIS设置后 直正HTML无法显示
查看>>
垃圾代码评析——关于《C程序设计伴侣》6.2(一)
查看>>
为 iPhone 和 iPad 自定义网站的主屏幕图标
查看>>
怎样快速搜索自己所需的资料?(90%的人不会使用此方法)[转]
查看>>
【Android】使用SearchView时软键盘不支持actionSearch的问题
查看>>
url请求返回结果测试工具(CURL)
查看>>
虚拟机安装教程
查看>>