370 midterm notes

This commit is contained in:
Medium Fries
2019-04-15 20:06:49 -07:00
parent 787e8bed86
commit 505c09500c
9 changed files with 266 additions and 7 deletions

View File

@@ -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)

View File

@@ -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.

View 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)