16-time-complexity

# 16-time-complexity - P and NP Definition P is the class of...

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: P and NP Definition: P is the class of languages that are decidable in polynomial time on a deterministic Turing machine, P = [ k TIME ( n k ) , for k ≥ . Definition: NP = [ k NTIME ( n k ) , for k ≥ . Observation: In order to prove that a language is a member of a particular complexity class we simply have to demonstrate than an appropriate algorithm exists. We have seen this in the case of the directed path in a graph. – p. 1/1 6 Properties of P and NP Theorem: The complexity class P is closed under complementation. Proof: Any language L ∈ P can be decided in deterministic polynomial time. Let M be such a decider for L . To show that P is closed under complementation we show that we can construct a deterministic polynomial time decider M ′ for L , M ′ = "On input w , where w is a string: 1. Run M on w . 2. If M accepts, reject ; if M rejects, accept ." It is easy to see that this machine runs in deterministic polynomial time. a50 – p. 2/1 6 Properties of P and NP Theorem: The complexity class NP is closed under the Kleene-closure. Proof: Any language L in NP is decided by some nondeterministic polynomial time TM. Let M be such a decider for L . To show that NP is closed under the Kleene-closure we need to show that L ∗ ∈ NP , where L ∗ = { w | w = ∅ or w = w 1 w 2 . . . w k for k ≥ 1 and each w i ∈ L } . We construct a nondeterministic polynomial time TM M ′ that decides L ∗ , M ′ = "On input w , where w is a string: 1. If w = ∅ , then accept . 2. Nondeterministically split w into the strings w 1 w 2 . . . w k for k ≥ 1 . 3. Run M on each string w i . 4. If M accepts all w i ’s, accept ; otherwise, reject ." By realizing that the number of times the machine M is invoked is bounded by O ( n ) (each | w i | = 1 with n = | w | ) and the fact that M is a nondeterministic polynomial time TM, say O ( n m ) , then the total nondeterministic polynomial runtime is O ( n m +1 ) . Therefore, L ∗ ∈ NP . a50 – p. 3/1 6 Hamiltonian Path A Hamiltonian path in a directed path is a directed path that goes through each node exactly once.A Hamiltonian path in a directed path is a directed path that goes through each node exactly once....
View Full Document

## This note was uploaded on 10/03/2011 for the course CSC 544 taught by Professor Staff during the Spring '11 term at Rhode Island.

### Page1 / 16

16-time-complexity - P and NP Definition P is the class of...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online