370 midterm notes
This commit is contained in:
@@ -21,7 +21,12 @@ Time: O(VlogV + E)
|
||||
|
||||
## Dijkstra's
|
||||
|
||||
O(V)
|
||||
O(V^2 + E)
|
||||
|
||||
## A\*
|
||||
O(V^2 = E)
|
||||
|
||||
Worst case is the same as Dijkstra's time
|
||||
|
||||
O(V^2 + E)
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ _time complexity will be in terms of height_
|
||||
* impl: _root will typically have the largest height value_
|
||||
|
||||
> Balance:
|
||||
| left_height - right_height |
|
||||
left_height - right_height
|
||||
we can discard the || if we want negative balance vals but it really shouldn't matter
|
||||
basically: we want the balance for each node to be 1 or 0.
|
||||
|
||||
|
||||
17
370/notes/single-source.md
Normal file
17
370/notes/single-source.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Single Source Shortest Path
|
||||
|
||||
# Bellman-ford Algorithm
|
||||
|
||||
Time: O(VE)
|
||||
|
||||
# Floyd-Warshall
|
||||
|
||||
Space: O(V^2)
|
||||
|
||||
That space is because we're using a matrix to store the paths, which of course is going to take up two dimensions
|
||||
|
||||
Main idea: Shortest path between any two nodes in a graph w/ V nodes _will_ go through at most V nodes
|
||||
|
||||
Iterative idea: Path's can visit i intermediary node. Does that many any path shorter?
|
||||
|
||||
Advantages: we can find negative cycles(Cycle where there is a negative edge)
|
||||
Reference in New Issue
Block a user