We shift our origin such that the hunter is at the origin.

The rabbit's original coordinate was x. ( Note that x can be positive , negative or zero ).

The basic observation is that once we reach to the original position of the rabbit, we can kill the
rabbit in atmost 3 steps:
By hitting at x (rabbit is killed if it was stationary)
2By hitting at x+d1 ( where d is a distance calculated by the algorithm explained below ) ( the
rabbit gets killed if it had moved right )
3By hitting at x-d2 ( where d2 is a distance calculated by the algorithm explained below ) ( the
rabbit gets killed if it had moved left )


Now, we have to devise an algorithm to find x.

We assume different initial locations for the rabbit until we kill the rabbit.

First, we assume that x=0.
We shoot at 0.
Case Ìf the rabbit was stationary, it gets killed.
eIse we shoot at 2.
Case 2 Ìf the rabbit was moving right, this time it gets killed.
eIse we shoot at -3
Case 3 Ìf the rabbit was moving left, this time it gets killed.

If the rabbit stiII doesn't die, we assume x=+1.
We shoot at 1.
Case Ìf the rabbit was stationary, it gets killed.
eIse we shoot at 6.( aIready 5 minutes have eIapsed. )
Case 2 Ìf the rabbit was moving right, this time it gets killed.
eIse we shoot at -5.( aIready 6 minutes have eIapsed. )
Case 3 Ìf the rabbit was moving left, this time it gets killed.


If the rabbit stiII doesn't die, we assume x=-1.
We shoot at -1.
Case Ìf the rabbit was stationary, it gets killed.
eIse we shoot at 7.( aIready 8 minutes have eIapsed. )
Case 2 Ìf the rabbit was moving right, this time it gets killed.
eIse we shoot at -10.( aIready 9 minutes have eIapsed. )
Case 3 Ìf the rabbit was moving left, this time it gets killed.

We continue the above process for x=+2 and x=-2 ,x=+3 and x=-3,...and so
on until we reach the actual x0.

e get the following table for the first few values of x:

Assumption for x Shooting points Time elapsed

0 0,2,-3 1,2,3
1 1,6,-5 4,5,6
-1 -1,7,-10 7,8,9
2 2,13,-10 10,11,12

-2 -2,12,-17 13,14,15
3 3,20,-15 16,17,18
-3 -3,17,-24 19,20,21
4 4,27,-19 22,23,24
-4 -4,22,-31 25,26,27
.....
.....



e observe that for a given x0, the time to reach x0 is :
Case 1: x0 is positive:
e need to go though 0,1,-1,2,-2,3,-3,...,x0-1,1-x0, before reaching x0.
Each of the checkpoints require 3 minutes. So, a total of [1+2*(x0-1)]*3 minutes
are required to reach x0. Thereafter, atmost 3 minutes are required to finish the
game. So, the total time is atmost [1+2*(x0-1)]*3+3=x = O(x).


Case 2: x0 is negative:
e need to go though 0,1,-1,2,-2,3,-3,...,-x0-1,1+x0,-x0 before reaching
x0. Each of the checkpoints require 3 minutes. So, a total of [1+2*(x0-1)]*3+3
minutes are required to reach x0. Thereafter, atmost 3 minutes are required to
finish the game. So, the total time is atmost [1+2*(x0-1)]*3+3+3=x+3 = O(x).

Case 3: x0 is zero:
This is a trivial case. It takes atmost 3 steps to finish the game.


ence, the rabbit is finished in O(x) time.






.97..20      03.9208.3  .9.54398706:7023:908 $4 .70706:70/94 13890.54398706:7023:908 $4 .70706:70/9470.9208.80   85489.09.80   830.20 $4 90949.08.41    ( 23:908 .0 907.1907 .9248923:908.                                                               04-807..70706:70/9413890 . %070.41     (   23:908.20 $4 90949. %070.0.0    0300/94494:              -0147070..4190..0.4190.0    0300/94494:           -0147070..9248923:908.949.1907 .9147..92489    (       ..3  .949.--981380/3  920          ..80 99.03 909209470...80   8074  %88.92489890589413890. 8 .70706:70/9470.92489    (        .

Sign up to vote on this title
UsefulNot useful