diff --git a/tech/BFS.wiki b/tech/BFS.wiki index b3c8458..6f62089 100644 --- a/tech/BFS.wiki +++ b/tech/BFS.wiki @@ -2,8 +2,8 @@ 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. +traverses the entire tree/graph. Therefore, BFS is often performed in O(|V| + +|E|) time. == Algorithm == @@ -18,3 +18,7 @@ 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]]. +=== Graph === + +Graph traversal is similar, however a list of visited nodes is required. This +is to ensure that we do not get stuck in loops diff --git a/tech/DFS.wiki b/tech/DFS.wiki index 6edb4fd..e3cfe83 100644 --- a/tech/DFS.wiki +++ b/tech/DFS.wiki @@ -1 +1,21 @@ = Depth First Search = + +Depth 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. Depth first search can also be thought of as a +type of prefix traversal + +== Algorithm == + +=== Tree === + +The algorithm is often implemented as a recursive function. For each node in +the graph, the function checks if the node's value is the desired value, and if +not immediately calls itself upon that nodes children. Due to this the +algorithm searches as deeply as possible first and foremost, before then +searching the width of the tree. + +=== Graph === + +Graph traversal is similar, however a list of of visited nodes is required. +This is to ensure that we do not get stuck in loops. diff --git a/tech/Dijkstra.wiki b/tech/Dijkstra.wiki new file mode 100644 index 0000000..436a485 --- /dev/null +++ b/tech/Dijkstra.wiki @@ -0,0 +1,22 @@ += Dijkstra's Algorithm = + +Dijkstra's Algorithm was created by Edsger W. Dijkstra, and is an algorithm +for finding the *shortest path between any two nodes in a graph*. This can be +thought of finding the best route from point A to point B on something like a +road map. This is also called a *routing protocol*. + +Dijkstra's Algorithm is a [[greedy_algorithm]]. + +== Algorithm == + +1) Choose some initial node to start from. Create a set of distances from this + node to all other nodes, and set their distance to infinite. This algorithm + will change these distances and attempt to find the fastest way to each node. +2) Mark all nodes as 'unvisited'. All of these nodes are part of a set. +3) For the current node, consider all of its unvisited neighbors and calculate + the distance from the start node to this node. + - For example, if the current node is marked as a distance of 6 from the + starting node, and the edge of neighbor _N1_ has a distance of 2, then + N1's distance is 6+2 = 8 + + diff --git a/tech/algorithms.wiki b/tech/algorithms.wiki index c75668b..89c7a38 100644 --- a/tech/algorithms.wiki +++ b/tech/algorithms.wiki @@ -24,8 +24,11 @@ Different ways to store and operate on data, with differing efficiency == Common Algorithms == +=== Graph and Tree === + * [[BFS]] * [[DFS]] +* [[Dijkstra]] == Sorting == diff --git a/tech/greedy_algorithm.wiki b/tech/greedy_algorithm.wiki new file mode 100644 index 0000000..af813ea --- /dev/null +++ b/tech/greedy_algorithm.wiki @@ -0,0 +1 @@ += Greedy Algorithm =