Breadth-First Search Algorithm in Javascript
Nov 12, 2020
Warning! This post is in the draft phase
1. Introduction
This is a graph traversal algorithm. That means, there is a tree structure, and we want to visit all points of the tree. Also, when we visit a point, we set new places to visit. At each visit, we log visited points and we set a new point to continue the journey. By doing so, we’ll be traveling all over this tree.
There are a lot of algorithm’s to do this
One of them is Breath-first search. It explores all directions equally. It’s perfect for some problems and quite easy to understand and implement. Let’s look at visuals to understand how breadth-first search works:
2. Warm-up
2.1. Definitions:
- node
- edges
- vertex
- starting point
- end point
- parent
- queue
2.2. Definitions for a node:
- n.state:
- n.