Chegg.com Interview Question for Consultants
- 0of 0 votes
Given two robots on an infinite line, they can move left or right. They cannot see each other. There is a marker between them that they can detect if they touch it. What algorithm will allow the bots to find each other (anywhere), if both bots are running the exact same algorithm?- Joe Shmoe August 19, 2009
You could have the bots go right then left in ever increasing distance. They will eventually find the marker. They could then stop and await the arrival of the other bot, or increase speed in that direction to catch up to it faster.
If the bots may only pick one direction and not change it, then they each pick, say, right, and move slowly until the marker is found, then increase speed to catch up to the other bot.
| Report Duplicate | Flag | PURGE
Chegg.com Consultant Brain Teasers
Open Chat in New Window