Docsity

Nondeterministic Complexity: The Classes NP and Co-NP, Punch-Card Puzzle, Slides of Computer Science

Partial preview of the text

Download Nondeterministic Complexity: The Classes NP and Co-NP, Punch-Card Puzzle and more Slides Computer Science in PDF only on Docsity!

The Class NP

Agenda

Nondeterministic complexity The class NP  Defined by…  …acceptance by poly-time NTM’s  …positive instance give poly-size proofs  …acceptance by poly-time verifiers  Examples in:  Punch-Card Puzzle  SAT (satisfiability of Boolean expressions)  Variants: CSAT, nSAT The class Co- NP Polynomial time reductions

A Punch-Card Puzzle

In general, the notches must always be there, as they go on 3 pegs, but holes may or may not be filled.

A Punch-Card Puzzle

Pictured are punch cards on the pegs:

A Punch-Card Puzzle

Q: Find a solution to this instance:

C1 C2 C3 C

A Punch-Card Puzzle

A: Solution is C1, C2, C3, flip(C4):

C1 C2 C3 C

A Punch-Card Puzzle

A: Solution is C1, C2, C3, flip(C4):

C1 C2 C3 C

A Punch-Card Puzzle

A: Solution is C1, C2, C3, flip(C4):

C1 C2 C3 C

Punch-Card Puzzle

is Decidable

A: Yes. Here’s an algorithm: SolvePuzzle(cards C1, C2, … C n) for(i 1 = 0 to 1) if (i 1 = 1) flip C for(i 2 = 0 to 1) if (i 2 = 1) flip C … for(in= 0 to 1) if (in= 1) flip Cn put cards on pegs if (no holes) ACCEPT REJECT Q: Running time? Docsity.com

Punch-Card Puzzle

is Decidable

A: Running time: In worst case, reject, and have to go through all possible iterations:

n nested for loops each with two

possibilities so worst-case running time is W(2^ n). Therefore, the algorithm has exponential running time.

Q: Can you come up with a polynomial- time algorithm?

Nondeterministic

Running Time

Recall that in a nondeterministic TM, a computation consists of a computation tree, whose branches from root to leaves are the various possible computations that could take place. DEF: The nondeterministic running time of a nondeterministic Turing machine N is the function f (n) which is the maximum number of transitions that N takes to halt (or crash) on any computation branch when given an arbitrary input of length n. Q: When is N said to be a decider?

Nondeterministic

Running Time

A: When f (n) is finite for all possible n.

Consider the NTM decider for (ab)*b(ab) (from lecture 16):

Q: What is the running time?

0 1 2 3

a|bR bR a|bR (^) • L

Nondeterministic

Running Time

height = f (5) = 6

0 1 2 3

a|bR bR a|bR (^) • L

0ababa a0baba ab0aba ab1aba aba0ba

abab0a abab1a

aba2ba crash

ababa0•

crash

ababa2• abab 3 a•

Nondeterministic Time

Complexity Classes

We can define language classes based on nondeterministic TM’s just as we did with deterministic TM’s

DEF: Suppose that g (n) is a real function. The nondeterministic time complexity class NTIME(g (n) ) consists of all languages which are decided by some NTM with running time O(g (n)). Any such language is said to be of nondeterministic time complexity g (n).

Q: Give a simple function g (n) for which previous example was in NTIME(g (n) ).