Pathfinding Algorithms in JavaScript - Maze solving

Published on Tuesday, September 1, 2015


Breadth-first search and depth-first search are two types of pathfinding algorithms commonly used to solve mazes, and find paths in maps and graphs. Depth-first is a kind of algorithm that uses a stack data structure to keep track of intersections to follow. Whenever you find a deadend, all you need to do is pop off all previously visited nodes from the stack. Breadth-first search leverages a queue instead of the stack, and steps through each node from all adjacent directions at the same time. Which algorithm is better? This totally depends on the maze at hand. JavaScript data types and algorithms lessons by Easy Learn Tutorial: learn how to become an expert software engineer and web developer! Copyright (c) 2015 Rodrigo Silveira -

Copyright © 2014-2017 EasyLearnTutorial. All rights reserved.