From 6af3d00da32e1b2f79393123eb2ba0ba2117e45c Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Fri, 5 Nov 2021 16:00:01 -0400 Subject: [PATCH] Update for 05-11-21 16:00 --- tech/BFS.wiki | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tech/BFS.wiki b/tech/BFS.wiki index d208b96..b3c8458 100644 --- a/tech/BFS.wiki +++ b/tech/BFS.wiki @@ -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]]. +