10 - 29 jan - recursion part 2
TRANSCRIPT
![Page 1: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/1.jpg)
CS 321. Algorithm Analysis & Design Lecture 10
Recursion - Continued.Independent Set
![Page 2: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/6.jpg)
![Page 7: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/7.jpg)
Let SAT(F) be an algorithm that returns YES if F is satisfiable and NO otherwise.
![Page 8: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/9.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/10.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/11.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/12.jpg)
Clauses of F
![Page 13: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/13.jpg)
Clauses of F
Contain x
![Page 14: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/14.jpg)
Clauses of F
Contain x
Contain (1-x)
![Page 15: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/15.jpg)
Clauses of F
Do not contain x
Contain x
Contain (1-x)
![Page 16: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/16.jpg)
Clauses of F[x=1]
Do not contain x
Contain x
Contain (1-x)
![Page 17: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/17.jpg)
Clauses of F[x=1]
Do not contain x
Contain (1-x)
![Page 18: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/18.jpg)
Clauses of F[x=1]
Do not contain x
Contain (1-x)
![Page 19: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/19.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/20.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/21.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/22.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/23.jpg)
![Page 24: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/24.jpg)
![Page 25: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/25.jpg)
![Page 26: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/26.jpg)
![Page 27: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/27.jpg)
T(n) = T(n-1) + T(n-2) + T(n-3)
![Page 28: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/28.jpg)
T(n) = T(n-1) + T(n-2) + T(n-3)
If T(n) < dcn, then:
![Page 29: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/29.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/30.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/31.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/32.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/33.jpg)
![Page 34: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/34.jpg)
![Page 35: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/35.jpg)
JeffE’s lecture notes, Lecture 4, p. 5
![Page 36: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/36.jpg)
JeffE’s lecture notes, Lecture 4, p. 5
![Page 37: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/37.jpg)
JeffE’s lecture notes, Lecture 4, p. 5
![Page 38: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/38.jpg)
JeffE’s lecture notes, Lecture 4, p. 5
![Page 39: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/39.jpg)
JeffE’s lecture notes, Lecture 4, p. 5
Eliminate degree zero vertices upfront to get:
![Page 40: 10 - 29 Jan - Recursion Part 2](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/40.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022051706/58efcbcc1a28ab830a8b45d3/html5/thumbnails/41.jpg)
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.