Update for 05-11-21 16:00

This commit is contained in:
Tyler Perkins 2021-11-05 16:00:01 -04:00
parent bcca992f03
commit 6af3d00da3

View File

@ -1 +1,20 @@
= Breadth First Search =
Breadth First Search is an algorithm for searching a tree/graph for a node that
has a certain property. It starts at some chosen/implied root node, and
traverses the entire tree/graph. Therefore, BFS is often performed in O(n)
time.
== Algorithm ==
=== Tree ===
The algorithm first starts by creating a Queue, Q, and a pointer to the current
node, curr. Starting at the root of the tree, all child nodes of the current
node are placed onto Q, then curr is changed to the first element of Q, which
is dequeued. This will traverse the tree from left to right, layer by layer. If
desired, a condition can be added for the desired node.
This method of traversal *does not* take advantage of the structure of a tree,
and therefore does not have any of the lookup advantages of a [[binary_tree]].