Question: Please give an algorithm that takes at most O(n) steps Door in a wall You are facing a wall that stretches infinitely in both directions.
Door in a wall You are facing a wall that stretches infinitely in both directions. There is a door in the wall, but you know neither how far away nor in which direction. You can see the door only when you are right next to it. Design an algorithm that enables you to reach the door by walking at most O(n) steps where n is the (unknown to you) number of steps between your initial position and the door. [Par95]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
