Lecture 23 - Review Flashcards
What’s the running time of Fast exponentiation? How is this obtained?
Q(logn)
Observation: x^2k = (x^2)^k and x^(2k+1) = x * (x^2)^k
What are the three proof techniques we learned?
- Loop invariants.
- Contradiction
- Cut and Paste
Prove that any subpath of a shortest path is a shortest path.
Suppose this path p is a shortest path from u to v. Then δ(u,v) = w(p) = w(pux) + w(pxy) + w(pyv). Now suppose there exists a shorter path p'xy. Then w(p’xy)
Prove the following Theorem 1: Let (S, V-S) be any cut that respects A, and let (u, v) be
a light edge crossing (S, V-S). Then, (u, v) is safe for A.
Lec 23 - Slide 29
Prove the correctness of Djikstra’s.
DIJKSTRA(V, E,w,s): INIT-SINGLE-SOURCE(V,s) S ← ∅ Q ← V while Q ≠ ∅ do ........u ← EXTRACT-MIN(Q) ........S ← S ∪ {u} ........for each vertex v∈Adj[u] do ................RELAX(u,v,w)
Initialization
Initially, S = ∅ ⟹ True
Loop Invariant:
At the start of each iteration:
d[v] = δ(s,v) ∀v ∈ S.
Termination:
Stops when Q=∅ ⇒
d[v] = δ(s,v) ∀ v ∈ V
(by Loop Invariant Property)
Maintenance:
Show that d[u] = δ(s,u) when
u is added to S in each
Iteration.
(check original lecture slide for proof)
Give the steps to calculate a min cut.
To find a min cut compute a max flow.
To find the cut run BFS (or DFS) from s on the residual graph.
The reachable vertices define the (min) cut.