BFS algorithm (explained such that even middle schooler understands):
BFS stands for Breadth-First Search, and it is a way to explore a graph or a maze in a systematic way. Imagine you are
in a maze and you want to find the exit. You start at the entrance of the maze, and you want to explore it in a way that
you don't miss any paths and you find the shortest path to the exit.
To use BFS, you start at the entrance of the maze and explore all the paths that are connected to it, such as the
corridors or rooms that are directly adjacent to it. Then, you explore all the paths that are connected to those paths,
and so on, until you find the exit.
To do this systematically, you use a queue, which is like a line of people waiting for something. In this case, you use
the queue to keep track of the paths you need to explore. You start by adding the entrance to the queue, and then you
explore the paths that are directly connected to it. For each of these paths, you add them to the end of the queue.
Then, you take the first path in the queue and explore the paths that are directly connected to it. For each of these
paths, you add them to the end of the queue. You keep doing this until you find the exit.
BFS guarantees that you will find the shortest path to the exit, because you explore all the paths that are the same
distance away from the entrance before you explore any paths that are farther away. So if there is a shorter path to the
exit, you will find it before you find a longer path.