BFS algorithm problem
Posted
by
Gorkamorka
on Stack Overflow
See other posts from Stack Overflow
or by Gorkamorka
Published on 2010-11-21T12:31:08Z
Indexed on
2011/01/04
22:53 UTC
Read the original article
Hit count: 251
The problem is as follows: A wanderer begins on the grid coordinates (x,y) and wants to reach the coordinates (0,0). From every gridpoint, the wanderer can go 8 steps north OR 3 steps south OR 5 steps east OR 6 steps west (8N/3S/5E/6W).
How can I find the shortest route from (X,Y) to (0,0) using breadth-first search?
Clarifications:
- Unlimited grid
- Negative coordinates are allowed
- A queue (linked list or array) must be used
- No obstacles present
© Stack Overflow or respective owner