Upload
winfred-atkins
View
212
Download
0
Embed Size (px)
Citation preview
CSCI 2670Introduction to Theory of
Computing
November 23, 2004
November 23, 2004 2
Agenda
• Today– Section 7.3
• Next week– Section 7.4
November 23, 2004 3
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 4
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 5
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 6
Example
• The bin-packing problem– Given a set of n items with weights w1,
w2, …, 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– b1, b2, …, bn 1 bi k
• Can we verify it in O(nk) time?
November 23, 2004 7
Verifier
M = “On input <w1, …, wn, b1, …, bn, k>
1. Initialize s1, s2, …, sk to 0
2. For i = 1, …, n3. if bi {1, 2, …, k} reject
4. sb_i = sb_i + wi
5. if sb_i > 1 reject
6. Next i7. Accept
November 23, 2004 8
The class NP
Definition: A verifier for a language A is an algorithm V, whereA={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 9
Why NP?
• The N in NP stands for non-deterministic
• Any language in NP can be non-deterministically solved in polynomial time using the verifier– Guess the certificate– Verify
November 23, 2004 10
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 uV’ or vV’
• There is no known polynomial solution to this problem
November 23, 2004 11
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 uV’ or
vV’• Takes O(|E|×k) time
November 23, 2004 12
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 13
Group problem 2
• Find a verifier for the traveling-salesman 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 14
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 15
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 16
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 17
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)?