064bdaf2eb3b414f504c5777016d6310.ppt
- Количество слайдов: 18
CSCI 2670 Introduction to Theory of Computing November 23, 2004
Agenda • Today – Section 7. 3 • Next week – Section 7. 4 November 23, 2004
Announcement • Office hours today 2: 30 – 3: 30 • No homework this week – No more graded homework – I will assign problems next week, but you won’t have to turn them in • Quiz next Wednesday (last quiz!) November 23, 2004
Last week • Big-O and small-o notation • Computational complexity depends on – Type of machine – Encoding • The class P – Algorithms that can be solved in O(nk) time on a single-tape deterministic TM using reasonable encoding November 23, 2004
Solving vs. verifying • What if we can’t solve the problem in O(nk) time? • Given a problem and a potential solution, can we verify the solution is correct? November 23, 2004 5
Example • The bin-packing problem – Given a set of n items with weights w 1, w 2, …, wn, and k bins that can hold a maximum weight of 1, can we place these items the bins? • There is no known O(nk) solution to this problem • What if we have a potential solution – b 1, b 2, …, bn 1 bi k • Can we verify it in 23, 2004 k) time? O(n November
Verifier M = “On input <w 1, …, wn, b 1, …, bn, k> 1. 2. 3. 4. 5. 6. 7. Initialize s 1, s 2, …, sk to 0 For i = 1, …, n if bi {1, 2, …, k} reject sb_i = sb_i + wi if sb_i > 1 reject Next i Accept November 23, 2004
The class NP Definition: A verifier for a language A is an algorithm V, where A={w|V accepts <w, c> for some string c} The string c is called a certificate of membership in A. Definition: NP is the class of languages that have polynomial-time verifiers. November 23, 2004
Why NP? • The N in NP stands for nondeterministic • Any language in NP can be nondeterministically solved in polynomial time using the verifier – Guess the certificate – Verify November 23, 2004
Other problems in NP • The vertex cover problem – Given a graph G = <V, E> and a number k in N, does there exist a subset V’ of V such that • |V’| = k • For every (u, v) E, either u V’ or v V’ • There is no known polynomial solution to this problem November 23, 2004
Vertex cover • Can we verify vertex cover in polynomial time? – Yes • What should the certificate be? – The subset V’ • How do we verify? – Check |V’| = k – Test that each (u, v) E has u V’ or v V’ • Takes O(|E|×k) time November 23, 2004
Group problem 1 • Find a verifier for the subset-sum problem – Given a finite set S N and a target t N, does there exist a subset S’ S such that the sum of all elements in S’ is equal to t? November 23, 2004
Group problem 2 • Find a verifier for the travelingsalesman problem – Given a weighted graph G (i. e. , a graph where each edge has a associated weight) and a distance d, does there exist a cycle through the graph that visits each vertex exactly once (except for the start/end vertex) and has a total distance d? November 23, 2004
Group problem 3 • Find a verifier for the set partition problem – Given a set S of number, does there exist a subset A of S such that the sum of all elements in A is equal to the sum of all elements in S-A? November 23, 2004
Group problem 4 • Find a verifier for the independent set problem – Given a graph G = <V, E> and a number k, does there exist a subset V’ of V such that |V’|=k and no edge in E connects 2 elements of V’? November 23, 2004
Group problem 5 • Find a verifier for the graph 3 colorability problem – Given a graph G = <V, E> is there a way of assigning the colors red, blue and green to the vertices of G such that no edge connects two nodes of the same color? November 23, 2004
Group problem 6 • Find a verifier for the cyclic ordering problem – Given a finite set A and a collection C of three-tuples of distinct elements of A (i. e. , for each (x, y, z) C, the elements x, y, and z are all in A and they are all different), is there a ono-to-one mapping f: A→{1, 2, …, |A|} such that for each (a, b, c) in C, f(a) < f(b) < f(c)? November 23, 2004
064bdaf2eb3b414f504c5777016d6310.ppt