Design an algorithm to walk along of the wall that meets


Problem

Lost in a land far away, you find yourself in front of a wall of infinite length to both sides (left and right). In the midst of total darkness, you carry a lamp that allows you to see only the portion of the wall that is exactly in front of you (the field of vision provided by the lamp is exactly the size of one of your steps). There is a door in the wall that you want to cross. Assuming that it is n steps from its initial position (it is not known whether to the right or to the left), design an algorithm to walk along of the wall that meets the door in O(n) steps. Assume that n is an unknown value (information belonging to the instance). Consider that the action composed by giving a step and check the position of the corresponding wall costs O(1).

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Design an algorithm to walk along of the wall that meets
Reference No:- TGS03223087

Expected delivery within 24 Hours