A short algorithm to find a path in a Maze, implementing linear data structures such as Queues (Linked List). The algorithm consists of the following;
- Initialize maze dimensions and walls. Set start and end positions
- Create a queue of the positions that will be visited, called toVisit.
- Set the current position to start. Add it to toVisit.
- Pop the current position from toVisit
- Verify if the current position is equal to the end position. If yes, we are done.
- For the current position, check its 4 neighbors and add them to a queue named neighbors
- Empty the neighbors queue and add them to toVisit.
- Go back to 4.