Update for 06-11-21 15:00
This commit is contained in:
parent
6af3d00da3
commit
8e284fc893
@ -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
|
||||
|
@ -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.
|
||||
|
22
tech/Dijkstra.wiki
Normal file
22
tech/Dijkstra.wiki
Normal file
@ -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
|
||||
|
||||
|
@ -24,8 +24,11 @@ Different ways to store and operate on data, with differing efficiency
|
||||
|
||||
== Common Algorithms ==
|
||||
|
||||
=== Graph and Tree ===
|
||||
|
||||
* [[BFS]]
|
||||
* [[DFS]]
|
||||
* [[Dijkstra]]
|
||||
|
||||
== Sorting ==
|
||||
|
||||
|
1
tech/greedy_algorithm.wiki
Normal file
1
tech/greedy_algorithm.wiki
Normal file
@ -0,0 +1 @@
|
||||
= Greedy Algorithm =
|
Loading…
Reference in New Issue
Block a user