10 - 29 jan - recursion part 2
TRANSCRIPT
CS 321. Algorithm Analysis & Design Lecture 10
Recursion - Continued.Independent Set
3CNF - WHAT’S THE BEST WE CAN DO?
Trivial Algorithm: Try all possible assignments.
Recursion?
O(2npoly(n))
3CNF - WHAT’S THE BEST WE CAN DO?
Trivial Algorithm: Try all possible assignments.
Recursion?
Pick a clause: (x + y + (1-z))
O(2npoly(n))
3CNF - WHAT’S THE BEST WE CAN DO?
Trivial Algorithm: Try all possible assignments.
Recursion?
Pick a clause: (x + y + (1-z))
SAT(F(x=1)), SAT(F(x = 0, y=1)), SAT(F(x = 0, y = 0, z=0))
O(2npoly(n))
3CNF - WHAT’S THE BEST WE CAN DO?
Trivial Algorithm: Try all possible assignments.
Recursion?
Pick a clause: (x + y + (1-z))
SAT(F(x=1)), SAT(F(x = 0, y=1)), SAT(F(x = 0, y = 0, z=0))
T(n) < T(n-1) + T(n-2) + T(n-3) + poly(n)
O(2npoly(n))
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
Suppose (x + y + (1-z)) is a clause in F.
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
Suppose (x + y + (1-z)) is a clause in F.
Any assignment that satisfies F also has to satisfy (x + y + (1-z)).
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
Suppose (x + y + (1-z)) is a clause in F.
Any assignment that satisfies F also has to satisfy (x + y + (1-z)).
Suppose t: V ⟼{0,1} satisfies F.
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
Suppose (x + y + (1-z)) is a clause in F.
Any assignment that satisfies F also has to satisfy (x + y + (1-z)).
Suppose t: V ⟼{0,1} satisfies F.
Either t(x) = 1 or t(y) = 1 or t(z) = 0
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
Clauses of F
Clauses of F
Contain x
Clauses of F
Contain x
Contain (1-x)
Clauses of F
Do not contain x
Contain x
Contain (1-x)
Clauses of F[x=1]
Do not contain x
Contain x
Contain (1-x)
Clauses of F[x=1]
Do not contain x
Contain (1-x)
Clauses of F[x=1]
Do not contain x
Contain (1-x)
Suppose (x + y + (1-z)) is a clause in F.
Any assignment that satisfies F also has to satisfy (x + y + (1-z)).
Suppose t: V ⟼{0,1} satisfies F.
Either t(x) = 1 or t(y) = 1 or t(z) = 0
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
Suppose (x + y + (1-z)) is a clause in F.
Any assignment that satisfies F also has to satisfy (x + y + (1-z)).
Suppose t: V ⟼{0,1} satisfies F.
Either t(x) = 1 or t(y) = 1 or t(z) = 0
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
If SAT(F[x=1]) returns YES, then the whole formula is satisfiable.
Suppose (x + y + (1-z)) is a clause in F.
Any assignment that satisfies F also has to satisfy (x + y + (1-z)).
Suppose t: V ⟼{0,1} satisfies F.
Either t(x) = 1 or t(y) = 1 or t(z) = 0
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
If SAT(F[x=1]) returns YES, then the whole formula is satisfiable.
Otherwise, any satisfying assignment must set x = 0.
Pick a clause: (x + y + (1-z))
SAT(F(x=1)), SAT(F(x = 0, y=1)), SAT(F(x = 0, y = 0, z=0))
T(n) < T(n-1) + T(n-2) + T(n-3) + poly(n)
T(n) = T(n-1) + T(n-2) + T(n-3)
T(n) = T(n-1) + T(n-2) + T(n-3)
If T(n) < dcn, then:
T(n) = T(n-1) + T(n-2) + T(n-3)
dc(n-1) + dc(n-2) + dc(n-3) ≤ dcn
If T(n) < dcn, then:
T(n) = T(n-1) + T(n-2) + T(n-3)
dc(n-1) + dc(n-2) + dc(n-3) ≤ dcn
If T(n) < dcn, then:
(Want to show)
T(n) = T(n-1) + T(n-2) + T(n-3)
dc(n-1) + dc(n-2) + dc(n-3) ≤ dcn
c3 - c2 - c1 - 1 = 0
If T(n) < dcn, then:
(Want to show)
T(n) = T(n-1) + T(n-2) + T(n-3)
dc(n-1) + dc(n-2) + dc(n-3) ≤ dcn
c3 - c2 - c1 - 1 = 0
Solving for c gives us c = 1.8-ish.
If T(n) < dcn, then:
(Want to show)
JeffE’s lecture notes, Lecture 4, p. 5
JeffE’s lecture notes, Lecture 4, p. 5
JeffE’s lecture notes, Lecture 4, p. 5
JeffE’s lecture notes, Lecture 4, p. 5
JeffE’s lecture notes, Lecture 4, p. 5
Eliminate degree zero vertices upfront to get:
JeffE’s lecture notes, Lecture 4, p. 5
Eliminate degree zero and degree one vertices upfront to get:
JeffE’s lecture notes, Lecture 4, p. 5
Same as before, plus deal with graphs of max-degree two in polynomial time, to get:
This is an example of using a “clever base case” to get an improved running time.