Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 2670 Introduction to Theory of Computing November 17, 2005.

Similar presentations


Presentation on theme: "CSCI 2670 Introduction to Theory of Computing November 17, 2005."— Presentation transcript:

1 CSCI 2670 Introduction to Theory of Computing November 17, 2005

2 Agenda Today –Finish Section 7.2 –Start Section 7.3

3 November 17, 2005 Announcement Homework due next Tuesday (11/22) –7.3 a, 7.4, 7.6 (union only), 7.9, 7.12 1st edition 7.3a, 7.4, 7.6 (union only), 7.10, 7.12

4 November 17, 2005 Last class Introduced the class P –P = U k TIME(n k ) Proved two languages are in P –Binary tree query –PATH

5 November 17, 2005 Another problem in P RELPRIME = { | x and y are relatively prime} RELPRIME  P How can we show this? –We cannot find prime factorization of x and y and compare –Use Euclidean algorithm for finding gcd(x,y)  RELPRIME iff gcd(x,y) = 1

6 November 17, 2005 Euclidean algorithm E = “On input, where x and y are natural numbers in binary: 1.Repeat until y = 0 1.Assign x  x mod y 2.Exchange x and y 2.Output x”

7 November 17, 2005 Solution to RELPRIME R = “On input, where x and y are natural numbers in binary: 1.Run E on 2.If result is 1, accept 3.Else reject”

8 November 17, 2005 Verify solution is in P Is R a decider? –Yes How long will it take R to run? –Execution of R is dominated by E –Note that if x > y, then (x mod y) < x/2 If x ≥ 2y, then x mod y < y ≤ x/2 If x < 2y, then x mod y = x – y < x/2 –Therefore loop in E is executed O(log 2 x) times Is this polynomial in the length of the input? –log2x = O(n), where n = length of input

9 November 17, 2005 Solving vs. verifying What if we don’t know how to solve the problem in O(n k ) time? Given a problem and a potential solution, can we verify the solution is correct?

10 November 17, 2005 Example The bin-packing problem –Given a set of n items with weights w 1, w 2, …, w n, and k bins that can hold a maximum weight of 1, can we place these items the bins? There is no known O(n k ) solution to this problem What if we have a potential solution –b 1, b 2, …, b n 1  b i  k Can we verify it in O(n k ) time?

11 November 17, 2005 Verifier M = “On input 1.Initialize s 1, s 2, …, s k to 0 2.For i = 1, …, n 3. if b i  {1, 2, …, k} reject 4. s b_i = s b_i + w i 5. if s b_i > 1 reject 6.Next i 7.Accept

12 November 17, 2005 The class NP Definition: A verifier for a language A is an algorithm V, where A={w|V accepts 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.

13 November 17, 2005 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

14 November 17, 2005 Other problems in NP The vertex cover problem –Given a graph G = 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

15 November 17, 2005 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

16 November 17, 2005 Example 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? V takes input S’ –Checks S’  S O(|S’| x |S|) = O(|S| 2 ) –Check Σ s  S’ s = t O(|S’|) = O(|S|)

17 November 17, 2005 Example 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?

18 November 17, 2005 Example 2 Find a verifier for the traveling- salesman problem V takes input Check the input is a permutation of the nodes of the graph –O(|V| 2 ) Check Σ 1≤k<n v ik = d –O(|E|x|V|)


Download ppt "CSCI 2670 Introduction to Theory of Computing November 17, 2005."

Similar presentations


Ads by Google