Technical Interview

Tips, questions, answers and puzzles at
www.technical-interview.com

Wednesday, February 7, 2007

You have to get from point A to

You have to get from point A to point B. You don’t know if you can get there. What would you do?

More questions at: www.technical-interview.com

6 comments:

  1. The two most common way to tackle problem like this is using Depth-First Search (DFS)and Breadth-First Search (BFS).
    In the example above, You drive and drive around until you hope to find the destination. Reach a deadend? Turn around and come back where you came from. It might not be the shortest way, but if you tried every possible road, you’ll know that maybe you can’t get to China from New York (And that’s a DFS!).Understanding these leads to you more exotic things like A* Search, and it’s a fundamental exploring algorithm. Too many things can be reduced into a graph, and knowing the best way to search a graph will come in handy. DFS is basically a stack-based implementation, while BFS is a queue-based implementation, and each with its strength and weaknesses.

    ReplyDelete
  2. Thank you for this post and the wonderful site. I agree with the answer above.

    ReplyDelete
  3. I would look up the address in a street directory and then take the shortest route possible.

    ReplyDelete
  4. I would use googlemaps

    ReplyDelete
  5. Since this was a question from google. I would say I would use google map. Remember it tells you how to get from point A to B.

    ReplyDelete