Logistics Quiz and exercise 7 released tomorrow Quiz























- Slides: 23
Logistics • Quiz and exercise 7 released tomorrow • Quiz due Tuesday at 11: 59 pm • Exercise due Friday 11: 59 pm – Just a few reductions 1
CS 3102 Theory of Computation www. cs. virginia. edu/~njb 2 b/cstheory/s 2020 Warm up: To measure the “cost” of computing something, what would units should we use?
Larger inputs = More time • 3
More time gives more functions 4
RAM Machine • 5
Finding Running Times • We will find running times for the following: – Shortest Path in a graph – Longest Path in a graph – 3 SAT – 2 SAT 6
Graphs s e d o N ices/ Vert Edg es B 10 8 E 8 H 7 A 9 5 D 12 3 C 1 G 6 2 9 3 F I 11 7
Adjacency List Representation B 10 A D 3 C E 7 9 12 8 1 8 H 5 3 F 6 2 9 I 11 G A B C B A C E C A B D D C E F E B D G F C D G G E F H H E G I I G H F H I 8
Adjacency Matrix Representation B 10 A D 3 C E 7 9 12 8 1 8 H 5 3 F 6 2 9 I 11 G A B C D A 1 B 1 1 1 C 1 1 D E 1 1 F G H I E F GH I 1 1 1 1 9
Definition: Path B 10 A C E 7 9 12 8 D 3 1 5 3 F 6 8 H 9 G 2 I 11 Simple Path: A path in which each node appears at most once 10
Shortest Path • B H A Shortest path from A to E has length 2 E D I C F G 11
Breadth First Search 12
Longest Path • 13
Longest Path • 14
(3 -)CNF • Conjunctive Normal Form (CNF) formula: – Logical AND of clauses – Each clause being an OR of variables • 3 -CNF: Each clause has 3 variables Clause Variables 15
3 -SAT • Given a 3 -CNF formula (logical AND of clauses, each an OR of 3 variables), Is there an assignment of true/false to each variable to make the formula true? Clause Variables 16
3 -SAT algorithm • 17
2 -SAT • Given a 2 -CNF formula (logical AND of clauses, each an OR of 2 variables), Is there an assignment of true/false to each variable to make the formula true? Clause Variables 18
2 -SAT in Polynomial Time • Convert formula to an “implication graph” Are there any cycles with a variable and its negation? 19
2 -SAT in Polynomial Time • Convert formula to an “implication graph” Are there any cycles with a variable and its negation? 20
3 -SAT algorithm • 21
Polynomial Time vs Exponential Time • 22
Tractability • Tractable: – Feasible to solve in the “real world” • Intractable: – Infeasible to solve in the “real world” • Whether a problem is considered “tractable” or “intractable” depends on the use case – For theory: Tractable = polynomial time, Intractable = Exponential time 23























