41
CS 321. Algorithm Analysis & Design Lecture 10 Recursion - Continued. Independent Set

10 - 29 Jan - Recursion Part 2

Embed Size (px)

Citation preview

Page 1: 10 - 29 Jan - Recursion Part 2

CS 321. Algorithm Analysis & Design Lecture 10

Recursion - Continued.Independent Set

Page 2: 10 - 29 Jan - Recursion Part 2

3CNF - WHAT’S THE BEST WE CAN DO?

Trivial Algorithm: Try all possible assignments.

Recursion?

O(2npoly(n))

Page 3: 10 - 29 Jan - Recursion Part 2

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

Page 4: 10 - 29 Jan - Recursion Part 2

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

Page 5: 10 - 29 Jan - Recursion Part 2

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

Page 6: 10 - 29 Jan - Recursion Part 2
Page 7: 10 - 29 Jan - Recursion Part 2

Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.

Page 8: 10 - 29 Jan - Recursion Part 2

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.

Page 9: 10 - 29 Jan - Recursion Part 2

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.

Page 10: 10 - 29 Jan - Recursion Part 2

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.

Page 11: 10 - 29 Jan - Recursion Part 2

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.

Page 12: 10 - 29 Jan - Recursion Part 2

Clauses of F

Page 13: 10 - 29 Jan - Recursion Part 2

Clauses of F

Contain x

Page 14: 10 - 29 Jan - Recursion Part 2

Clauses of F

Contain x

Contain (1-x)

Page 15: 10 - 29 Jan - Recursion Part 2

Clauses of F

Do not contain x

Contain x

Contain (1-x)

Page 16: 10 - 29 Jan - Recursion Part 2

Clauses of F[x=1]

Do not contain x

Contain x

Contain (1-x)

Page 17: 10 - 29 Jan - Recursion Part 2

Clauses of F[x=1]

Do not contain x

Contain (1-x)

Page 18: 10 - 29 Jan - Recursion Part 2

Clauses of F[x=1]

Do not contain x

Contain (1-x)

Page 19: 10 - 29 Jan - Recursion Part 2

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.

Page 20: 10 - 29 Jan - Recursion Part 2

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.

Page 21: 10 - 29 Jan - Recursion Part 2

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.

Page 22: 10 - 29 Jan - Recursion Part 2

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)

Page 23: 10 - 29 Jan - Recursion Part 2
Page 24: 10 - 29 Jan - Recursion Part 2
Page 25: 10 - 29 Jan - Recursion Part 2
Page 26: 10 - 29 Jan - Recursion Part 2
Page 27: 10 - 29 Jan - Recursion Part 2

T(n) = T(n-1) + T(n-2) + T(n-3)

Page 28: 10 - 29 Jan - Recursion Part 2

T(n) = T(n-1) + T(n-2) + T(n-3)

If T(n) < dcn, then:

Page 29: 10 - 29 Jan - Recursion Part 2

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:

Page 30: 10 - 29 Jan - Recursion Part 2

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)

Page 31: 10 - 29 Jan - Recursion Part 2

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)

Page 32: 10 - 29 Jan - Recursion Part 2

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)

Page 33: 10 - 29 Jan - Recursion Part 2
Page 34: 10 - 29 Jan - Recursion Part 2
Page 35: 10 - 29 Jan - Recursion Part 2

JeffE’s lecture notes, Lecture 4, p. 5

Page 36: 10 - 29 Jan - Recursion Part 2

JeffE’s lecture notes, Lecture 4, p. 5

Page 37: 10 - 29 Jan - Recursion Part 2

JeffE’s lecture notes, Lecture 4, p. 5

Page 38: 10 - 29 Jan - Recursion Part 2

JeffE’s lecture notes, Lecture 4, p. 5

Page 39: 10 - 29 Jan - Recursion Part 2

JeffE’s lecture notes, Lecture 4, p. 5

Eliminate degree zero vertices upfront to get:

Page 40: 10 - 29 Jan - Recursion Part 2

JeffE’s lecture notes, Lecture 4, p. 5

Eliminate degree zero and degree one vertices upfront to get:

Page 41: 10 - 29 Jan - Recursion Part 2

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.