24
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.

Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Embed Size (px)

Citation preview

Page 1: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Complexity

Non-determinism.NP complete problems. Does P=NP?

Origami.Homework: continue on postings.

Page 2: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Decidability

• A language is decidable (aka Turing decidable) if a TM decides it, meaning it halts in an accepting or a non-accepting state. – It does not loop.

Page 3: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Non-determinism

• Concept that can be applied to FSA, PDA, and TM

• Start with FSA– NDFSA has choices at each state– So a NDFSA has finite set of states, finite

alphabet, start state, set of accepting states and rules of the form State x (Alphabet + empty string) =>subset of states.

• Think of it as choices

Page 4: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Non-determinism

• extend to PDA and TM

• In terms of computation power, for every NDFSA there is a (standard) FSA and the same holds for PDAs and TMs.– increase states to be set of all subsets of the

states.– This is an exponential increase in number of

states.

Page 5: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Consider

• Consider original set of states, the the Power set is the set of all subsets:– For {a,b}, the is the empty set, {a},{b} and

{a,b} – for {a,b,c} ?– for {a,b,c,d} ?– Generalize?

Page 6: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Back to complexity

• So adding the non-determinism option (may think of it as guessing a solution), doesn't effect the programming power but does effect the complexity.

Page 7: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Fact

• If T is a non-deterministic TM that computes in O(f(n)), then there is a deterministic TM that computes in 2 O(f(n)) .

• The proof (look it up!) does not mean there isn't a faster deterministic TM.

Page 8: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

The class P

• consists of all languages that are decidable in polynomial time by a deterministic TM.

• P = UNION TIME(nk)• These correspond to all problems that are

realistically solvable– though there is a big difference between

problems solvable in linear time and problems solvable only in n2 or n3 or higher

Page 9: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Examples of languages in P

• Every regular language

• Every context free language

Page 10: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Question

• If the requirement was to sort a set of 10000 records, then what would be the difference between using a bubble sort and a heap sort?

Page 11: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

The class NP

• consists of all languages that are decidable in polynomial time by a nondeterministic TM.

• NP = UNION NTIME (nk)

Page 12: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Examples of NP

• clique = {<G,k< | G is an undirected graph with a k-clique (subgraph with every pair of nodes connected)

• …

Page 13: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

The class NP

• alternate definition: verifier• Informal idea: if we had some information, called

a certificate or proof and a way of using this certificate, then we have a verifier.

• Formal, a verifier for a language A is an algorithm V, whereA = {w | V accepts <w,c> for some c}

• NP is the set of languages that have polynomial time verifiers.

Page 14: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Generic Example

• Problem is: does there exist a path

• Verifier could be the path which can be checked in polynomial time.

Page 15: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

P versus NP

• P is the class of languages for which membership can be decided quickly.

• NP is the class of languages for which membership can be verified quickly.– where quickly means polynomial time.

Page 16: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Does P = NP?

• It is known how to produce a deterministic TM that does the job, but much slower involving a exponential increase in the number of states.

• But perhaps there is something better?

Page 17: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

NP-completeness

• A large and growing number of NP problems that can be converted into each other in polynomial time.

• … MEANING that if one can be solved in polynomial time, they all can be.

Page 18: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Example: Satisfiability

• A Boolean formula is an expression consisting of Boolean (true/false) variables and AND and OR and NOT operators.

• A formula is satisfiable if there is an assignment to its variables that makes the formula true.– x AND NOT x is NOT satisfiable

• SAT = {<w> | w is satisfiable }• SAT is in NP. Is it in P?

Page 19: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Travelling salesman

• Different versions

• Given a directed, weighted graph (edges have direction and values), – what is the shortest path to visit all nodes and

return to start– Is there a path of length less than some value

L that visits all nodes• This is NP-complete, meaning it can be converted

to others in the set, including satisfiability

Page 20: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

NP-hard

• A problem is NP-hard if solving it in polynomial tiam would mean that NP complete problems can be solved in polynomial time.

• It is at least as difficult as the NP-complete problems

• but maybe harder…

Page 21: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Note

• Repeat: NP complete problems and NP-hard problems are solvable, but take a lot of time.

• Note: the Travelling Salesman problem can be solved: try every path and pick the shortest.

• Intuitively: adding non-determinism is making a guess.– perhaps over a small set of possibilities

Page 22: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Origami example

• Fold and cut to make any polygon shape: http://erikdemaine.org/foldcut/– Inspiration may have been:

http://www.ushistory.org/betsy/flagstar.html

• Extra credit opportunity: what is the complexity of either or both of the algorithms that solve this problem?

Page 24: Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings

Homework

• [Can count as this week's posting, though you are welcome to give another one]

• Find a unique problem (unique with respect to what has been posted) of an NP complete problem.– explain problem and– give two sources