World Quant 面试题-4

Question:

一条东西向长街,你站在街中间,街北是一排门,你有一把钥匙,请写出一种策略,要求X/N在最坏情况下最少,X为你到达正确的门时所走的总路程,N为正确的门距原点的距离,可以假设门与门之间距离为1。

 

Definition:

1.      There are 2*m houses in all

2.      X is total distance traveled when open the rightdoor

3.      N is distance from right door to middle point

4.      Regard distance from middle point to the two nearbyhouses as 1, though it should be 0.5. This does not affect the result.

Solution #1: The first idea.

                First gothrough left m houses by order. If the right house is not found, go to theright side.  The worst case occurs whenright first house matches with key. Worst limit is: (1 + 2*m) .

Solution #2: An intuitional try.

                Can theworst case improve if we first go left, but turn right at the middle point,then go through m houses at right, afterwards, check the remaining houses. Let m=

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值