P, NP, and NP-Complete Problems Section 10.3 The class P consists of all problems that can be solved in polynomial time, O(N k ), by deterministic computers.

Slides:



Advertisements
Similar presentations
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Advertisements

Problems and Their Classes
Limitation of Computation Power – P, NP, and NP-complete
Single Source Shortest Paths
Weighted graphs Example Consider the following graph, where nodes represent cities, and edges show if there is a direct flight between each pair of cities.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
Complexity Theory CSE 331 Section 2 James Daly. Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on.
Chapter 1 pp 1-14 Properties of Algorithms Pseudocode.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Themes of Presentations Rule-based systems/expert systems (Catie) Software Engineering (Khansiri) Fuzzy Logic (Mark) Configuration Systems (Sudhan) *
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Programming & Data Structures
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
CSC 413/513: Intro to Algorithms NP Completeness.
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Although this may seem a paradox, all exact science is dominated by the idea of approximation. Bertrand Russell Approximation Algorithm.
Lecture 38 CSE 331 Dec 2, Review Sessions etc. Atri: (at least ½ of) class next Friday Jiun-Jie: Extra office hour next Friday Jesse: Review Session.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
CSCI 2670 Introduction to Theory of Computing November 17, 2005.
LIMITATIONS OF ALGORITHM POWER
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NPC.
Lecture 38 CSE 331 Dec 5, OHs today (only online 9:30-11)
Optimization/Decision Problems Optimization Problems – An optimization problem is one which asks, “What is the optimal solution to problem X?” – Examples:
Introduction to NP-complete. The relationship between Tai-yi schedule and Memory management. Kai – Po
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
Limitation of Computation Power – P, NP, and NP-complete
The NP class. NP-completeness
CS 583 Fall 2006 Analysis of Algorithms
ICS 353: Design and Analysis of Algorithms
Shortest Path Consider the following weighted undirected graph: 20 10
Chapter 11 Limitations of Algorithm Power
The Theory of NP-Completeness
CSE 589 Applied Algorithms Spring 1999
RAIK 283 Data Structures & Algorithms
Presentation transcript:

P, NP, and NP-Complete Problems Section 10.3

The class P consists of all problems that can be solved in polynomial time, O(N k ), by deterministic computers (the ones that you have used all your life!). Examples: Adding two numbers: Extracting the element with the highest priority from a heap: Looking for an element in an array: Looking for the MST: O(1) “constant” O(log N) “logarithmic” (thus, O(N) because N  log N ) O(N) “lineal” O(N log N) (thus, O(N 2 ) )

What does Deterministic Computer Means? (Idea) (For details: see CSE 318) 1. Computer Memory At every computational cycle we have the so-called state of the computation: 3. Program … …. 3. Program … …. State = (1. memory, 2. location of memory being pointed at, 3. program, 4. current instruction) 2 4

What does Deterministic Computer Means? (Idea- II) Computer Memory In a deterministic computer we can determine in advance for every computational cycle, the output state by looking at the input state Program … …. Program … …. InputOutput

Our Favorite Example search(el, A, i) { if (A[i] = el) then return i else return search(el, A, i+1) } el = 9 Complexity: O(N) //input: an array A[1..N] and an element el that is in the array //output: the position of el in A

Djikstra’s Shortest Path Algorithm A 6 B 3 C 3 D 2 E H 4 If the source is A, which edge is selected in the next iteration? Complexity: O(N log N) ( N = number of edges + vertices)

What does NonDeterministic Computer Means? Computer Memory In a nondeterministic computer we may have more than one output state. Program … …. Program … …. Output-1Output-2 The computer “chooses” the correct one (“nondeterministic choice”)

Nondeterministic Computers Seem More powerful Than Deterministic Ones nonDeterministicSearch(el, A) { return i } el = 9 There may be problems that are solvable by nondeterministic computers which are not solvable by deterministic ones Informally: Calls an Oracle who makes the right choice i  ohOracle(el, A, 1)

But They Are Not More Powerful nonDeterministicSearch(el, A) { i  ohOracle(el, A, 1) return i } ohOracle(el, A, i) { if (A[i] = el) then return i else return ohOracle(el, A, i+1) } Key result: Every program for a nondeterministic computer can be simulated by a deterministic one (CSE 318) Thus, they solve the same problems

But What About the Complexity? search(el, A, i, N) { if (A[i] = el) then return i else return search(el, A, i+1,N) } Complexity: O(N) OracleSearch(el, A, N) { i  Oracle(el, A, N) return i } Complexity: O(1)

Formal Definition: Nondeterministic Algorithms Phase1(el, A) { return i } A nondeterministic algorithm for a problem A is a two- stage procedure. In the first phase, a procedure makes a guess about the possible solution for A. In the second phase, a procedure checks if the guessed solution is indeed a solution for A i  random(1..N) Phase2(i,el, A) { return } A[i] == el Note: the actual solution must be included among the possible guesses of phase 1

NP Complexity The class NP consists of all problems that can be solved in polynomial time by nondeterministic algorithms If A is a problem in P then A is a problem in NP because The key question is are there problems in NP that are not in P or is P = NP? We don’t know the answer to the previous question (that is, both phase 1 and phase 2 run in polynomial time) Phase 1: use the polynomial algorithm that solves A Phase 2: write a constant time procedure that always returns true

NP Complexity (II) How to proof that a problem A is in NP: 1. Show that A is in P, or 2. Write a nondeterministic algorithm solving A that runs in polynomial time

Example Showing that searching for an element in an array is in P: 1. Write the procedure search(el, A, i) (Slide 5) which runs in lineal time, or 2. Write a non-deterministic algorithm solving search (Slide 11; both Phase 1 and Phase 2 run in constant time)

Homework Both sections: write a nickname so I can post your grades on the web and you remain anonym Section 010:  Section 9.4: 3.b, 4, 6  Construct a nondeterministic algorithm computing the MST for an input graph (pseudocode). For phase 2 assume that the minimum cost is known in advance. What is the complexity of this algorithm?  Construct a nondeterministic algorithm solving the traveling salesman person problem (pseudocode). For phase 2 assume that the minimum cost is known in advance. What is the complexity of this algorithm? Section 011:  Section 9.4: 3.a, 5.a, 5.b  Construct a nondeterministic algorithm computing the shortest path from a node u to a node v in an input graph (pseudocode). For phase 2 assume that the minimum cost is known in advance. What is the complexity of this algorithm?  Construct a nondeterministic algorithm solving the Knapsack problem (pseudocode). For phase 2 assume that the minimum cost is known in advance. What is the complexity of this algorithm?