please DO NOT COPY from other chegg posts or else it will be reported as SPAM. You are facing a river that stretches for a very long distance in both directions, in a straight line. There is a bridge but you do not know how far away or in what direction. It is dark and you only have a flashlight that allows you to see only see a bridge when you are right next to it. Design an algorithm that takes you to the bridge by walking at most O(n) steps where n is the distance between your initial position and the bridge. Analyze the number of steps you walk in the worst case exactly (i.e., without using asymptotics). Argue that it is not possible to do asymptotically better than this algorithm. please make it as clear as possible and use more specifications.
please DO NOT COPY from other chegg posts or else it will be reported as SPAM.
You are facing a river that stretches for a very long distance in both directions, in a straight line. There is a bridge but you do not know how far away or in what direction. It is dark and you only have a flashlight that allows you to see only see a bridge when you are right next to it. Design an algorithm that takes you to the bridge by walking at most O(n) steps where n is the distance between your initial position and the bridge. Analyze the number of steps you walk in the worst case exactly (i.e., without using asymptotics). Argue that it is not possible to do asymptotically better than this algorithm.
please make it as clear as possible and use more specifications.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps