CSCI 2670 Introduction to Theory of Computing - PowerPoint PPT Presentation

About This Presentation
Title:

CSCI 2670 Introduction to Theory of Computing

Description:

Title: PowerPoint Presentation Author: Wim van Dam Last modified by: Shelby Funk Created Date: 8/27/2001 7:35:01 AM Document presentation format: Letter Paper (8.5x11 in) – PowerPoint PPT presentation

Number of Views:139
Avg rating:3.0/5.0
Slides: 18
Provided by: Wim137
Learn more at: http://cobweb.cs.uga.edu
Category:

less

Transcript and Presenter's Notes

Title: CSCI 2670 Introduction to Theory of Computing


1
CSCI 2670Introduction to Theory of Computing
November 17, 2005
2
Agenda
  • Today
  • Finish Section 7.2
  • Start Section 7.3

3
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
Last class
  • Introduced the class P
  • P Uk TIME(nk)
  • Proved two languages are in P
  • Binary tree query
  • PATH

5
Another problem in P
  • RELPRIME ltx,ygt 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)
  • ltx,ygt?RELPRIME iff gcd(x,y) 1

6
Euclidean algorithm
  • E On input ltx,ygt, where x and y are natural
    numbers in binary
  • Repeat until y 0
  • Assign x ? x mod y
  • Exchange x and y
  • Output x

7
Solution to RELPRIME
  • R On input ltx,ygt, where x and y are natural
    numbers in binary
  • Run E on ltx,ygt
  • If result is 1, accept
  • Else reject

8
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 gt y, then (x mod y) lt x/2
  • If x 2y, then x mod y lt y x/2
  • If x lt 2y, then x mod y x y lt x/2
  • Therefore loop in E is executed O(log2x) times
  • Is this polynomial in the length of the input?
  • log2x O(n), where n length of input

9
Solving vs. verifying
  • What if we dont know how to solve the problem in
    O(nk) time?
  • Given a problem and a potential solution, can we
    verify the solution is correct?

10
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?

11
Verifier
  • M On input ltw1, , wn, b1, , bn, kgt
  • Initialize s1, s2, , sk to 0
  • For i 1, , n
  • if bi ? 1, 2, , k reject
  • sb_i sb_i wi
  • if sb_i gt 1 reject
  • Next i
  • Accept

12
The class NP
  • Definition A verifier for a language A is an
    algorithm V, where
  • AwV accepts ltw,cgt 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
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
Other problems in NP
  • The vertex cover problem
  • Given a graph G ltV,Egt 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
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(Ek) time

16
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(S2)
  • Check Ss?S s t
  • O(S) O(S)

17
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
Example 2
  • Find a verifier for the traveling-salesman
    problem
  • V takes input ltvi1,vi2,,vingt
  • Check the input is a permutation of the nodes of
    the graph
  • O(V2)
  • Check S1kltnvik d
  • O(ExV)
Write a Comment
User Comments (0)
About PowerShow.com