Movatterモバイル変換


[0]ホーム

URL:


Uploaded bychidabdu
PDF, PPTX3,626 views

Algorithm chapter 10

This document discusses P, NP and NP-complete problems. It begins by introducing tractable and intractable problems, and defines problems that can be solved in polynomial time as tractable, while problems that cannot are intractable. It then discusses the classes P and NP, with P containing problems that can be solved deterministically in polynomial time, and NP containing problems that can be solved non-deterministically in polynomial time. The document concludes by defining NP-complete problems as those in NP that are as hard as any other problem in the class, in that any NP problem can be reduced to an NP-complete problem in polynomial time.

In this document
Powered by AI

Discusses P, NP, and NP-Complete problems and introduces exponential complexity.

Lists classic problems like Sorting, Traveling Salesman, and Knapsack that are studied.

Defines tractable (polynomial time) vs intractable problems and introduces polynomial time.

Discusses methods to classify problems based on the existence of polynomial-time algorithms.

Distinguishes between optimization and decision problems with an example of Hamiltonian circles.

Explains optimization and decision versions of Traveling Salesman, Knapsack, and Bin Packing problems.

Defines class P, the solvability of decision problems, and mentions undecidable problems like the halting problem.

Defines NP problems, focusing on how proposed solutions can be quickly verified, and discusses nondeterministic algorithms.

Provides examples including graph coloring and CNF satisfiability problem highlighting their NP status.

Discusses the relationship between P and NP, establishing that P is a subset of NP and the question of equality.

Defines NP-completeness, hardest problems in NP, and implications for polynomial bounded algorithms.

Gives examples of polynomial reductions, clarifying how to transform problems for NP-completeness.

Formally defines NP-completeness and discusses Cook's theorem and implications in computational theory.

Embed presentation

Download as PDF, PPTX
P, NP and NP-CompleteProblems
Introduction An algorithm with O(n3) complexity isn’t bad because it can still be run for fairly large inputs in a reasonable amount of time. In this chapter, we are concerned with problems with exponential complexity. Tractable and intractable problems Study the class of problems for which no reasonably fast algorithms have been found, but no one can prove that fast algorithms do not exist.                                           2
Our Old List of Problems Sorting Searching Shortest paths in a graph Minimum spanning tree Traveling salesman problem Knapsack problem Towers of Hanoi                              3
TractabilityAn algorithm solves the problem inpolynomial time if its worst-case timeefficiency belongs to O(p(n)) where p(n) is apolynomial of the problem’s input size n.Problems that can be solved in polynomialtime are called tractable.Problems that cannot be solved in polynomialtime are called intractable.                                                4
Classifying a Problem’s ComplexityIs there a polynomial-time algorithm that solves the   problem?Possible answers:  yes  no      because it can be proved that all algorithms take      exponential time      because it can be proved that no algorithm exists at all      to solve this problem  don’t know, but if such algorithms were to be found, then  it would provide a means of solving many other problems  in polynomial time                                                             5
Types of ProblemsOptimization problem: construct a solution thatmaximizes or minimizes some objective functionDecision problem: A question that has twopossible answers, yes and no.  Example: Hamiltonian circles: A Hamiltonian circle in  an undirected graph is a simple circle that passes  through every vertex exactly once. The decision  problem is: Does a given undirected graph have a  Hamiltonian circle?                                                      6
Some More Problems (1)Many problems will have decision and optimization versions  Traveling salesman problem     Optimization problem: Given a weighted graph, find Hamiltonian cycle of     minimum weight.     Decision problem: Given a weighted graph and an integer k, is there a     Hamiltonian cycle with total weight at most k?  Knapsack : Suppose we have a knapsack of capacity W (a positive  integer) and n objects with weights w1, …, wn, and values v1, …, vn  (where w1, …, wn, and v1, …, vn are positive integers)     Optimization problem: Find the largest total value of any subset of the     objects that fits in the knapsack (and find a subset that achieves the     maximum value)     Decision problem: Given k, is there a subset of the objects that fits in the     knapsack and has total value at least k?                                                                              7
Some More Problems (2)Bin packing: Suppose we have an unlimited number of bins each ofcapacity one, and n objects with sizes s1, …, sn, where 0 ≤ si≤ 1( siare rational numbers)   Optimization problem: Determine the smallest number of bins into which   the objects can be packed(and find an optimal packing).   Decision problem: Given, in addition to the inputs described, an integer   k, do the objects fit in k bins?Graph coloring:   coloring: assign a color to each vertex so that adjacent vertices are not   assigned the same color.   Chromatic number: the smallest number of colors needed to color G.We are given an undirected graph G = (V, E) to be colored.   Optimization problem: Given G, determine the chromatic number .   Decision problem: Given G and a positive integer k, is there a coloring of   G using at most k colors? If so, G is said to be k-colorable.           8
The class PP : the class of decision problems that can be solved in   O(p(n)), where p(n) is a polynomial on n.Why use the existence of a polynomial time bound as the criterion?  if not, very inefficient  nice closure properties                     Given a computer program  machine independent in a strong sense       and an input to it,                                              determine whether the                                              program will halt on thatWhat is the solvability of a decision problem?                                              input or continue working  Solvable/decidable in polynomial time       indefinitely on it.  Solvable/decidable but intractable  Unsolvable/undecidable problems: e.g., the halting problem  No polynomial algorithm has been found, nor has the impossibility of  such an algorithm been proved.                                     9
The class NPInformally, NP is the class of decision problems for which a given proposed   solution for a given input can be checked quickly(in polynomial time) to   see if it really is a solution.Formally, NP: the class of decision problems that can be solved by   nondeterministic polynomial (NP) algorithms   A nondeterministic algorithm: a two-stage procedure that takes as its input   an instance I of a decision problem and does the following       “guessing” stage: An arbitrary string S is generated that can be       thought of as a guess at a solution for the given instance (but may be       complete gibberish as well)       “verification” stage: A deterministic algorithm takes both I and S as its       input and check if S is a solution to instance I, (outputs yes if s is a       solution and outputs no or not halt at all otherwise)                                                                           10
The class NP A nondeterministic algorithm solves a decision problem if and only if for every yes instance of the problem it returns yes on some execution. A nondeterministic algorithm is said to be polynomially bounded if there is a polynomial p such that for each input of size n for which the answer is yes, there is some execution of the algorithm that produces a yes output in at most p(n) steps.                                                             11
Example: graph coloring Nondeterministic graph coloring   First phase: generate a string s, a list of   characters, c1c2…cq ,which the second   phase interpret as a proposed coloring   solution   Second phase: interpret the above   characters as colors to be assigned to the   vertices ci   vi                                            12
Example: CNF Satisfiability     The problem: Given a boolean expression expressed in     conjunctive normal form(CNF), can we assign values     true and false to variables to satisfy the CNF ?     This problem is in NP. Nondeterministic algorithm:       Guess truth assignment                     Make the formula true       Check assignment to see if it satisfies CNF formula     Example:(A⋁¬B ⋁ ¬C ) ⋀ (¬A ⋁ B) ⋀ (¬ B ⋁ D ⋁ E ) ⋀ (F ⋁ ¬ D)     Truth assignments:     A B   CD    E   F1.   0 1   1 0   1   0                   literals2.   1 0   0 0   0   13.   1 1   0 0   0   14.   …                                                              13
The Relationship between P & NP (1)P ⊆ NP  (I ∈ P I ∈ NP): Every decision problem solvable  by a polynomial time deterministic algorithm is  also solvable by a polynomial time  nondeterministic algorithm.  To see this, observe that any deterministic  algorithm can be used as the checking stage of a  nondeterministic algorithm.    If I ∈ P, and A is any polynomial deterministic algorithm    for I, we can obtain a polynomial nondeterministic    algorithm for I merely by using A as the checking stage    and ignoring the guess. Thus I ∈ P implies I ∈ NP                                                                14
The Relationship between P & NP (2)  ?P = NP (NP ⊆ P?)  Can the problems in NP be solved in  polynomial time?  A tentative view                              NP                          P                                        15
NP-Completeness (1)NP-completeness is the term used to describe decisionproblems that are the hardest ones in NP  If there were a polynomial bounded algorithm for an NP-  complete problem, then there would be a polynomial bounded  algorithm for each problem in NP.  Examples     Hamiltonian cycle     Traveling salesman     Knapsack     Bin packing     Graph coloring     Satisfiability                                                          16
Informal Definition of NP-Completeness    Informally, an NP-complete problem is a problem in    NP that is as difficult as any other problem in this    class, because by definition, any other problem in NP    can be reduced to it in polynomial time.    A decision problem D1 is said to be polynomially    reducible to a decision problem D2 if there exists a    function t that transforms instances of D1 to instances    of D2 such that        1. t maps all yes instances of D1 to yes instances of D2 and        all no instances of D1 to all no instances of D2.        2. t is computable by a polynomial-time algorithm.If D2 is polynomially solvable, then D1 can also be solved in polynomial time.                                                                            17
An Example of Polynomial Reductions Problem P: Given a sequence of Boolean values, does at least one of them have the value true? Problem Q: Given a sequence of integers, is the maximum of the integers positive? Transformation T: t(x1, x2, …, xn) = (y1, y2, …, yn), where  yi = 1 if xi = true, and yi = 0 if xi = false.                                               18
Another Example of Polynomial ReductionsFor example  a Hamiltonian circuit problem is polynomially reducible to the  decision version of the traveling salesman problem.     Hamiltonian circuit problem(HCP): Does a given undirected graph have     a Hamiltonian cycle?     Traveling salesman problem(TSP): Given a weighted graph and an     integer k, is there a Hamiltonian cycle with total weight at most k?     Transformation t:          Map G, a given instance of the HCP to a weighted complete graph G’,          an instance of the TSP by assigning 1 as the edge weight to each          edge in G and adding an edge of weight 2 between any pair of          nonadjacent vertices in G.          Let k be n, the total vertex number in G.                                                                            19
Formal Definition of NP-CompletenessA decision problem D is said to be NP-complete if    1. It belongs to class NP.    2. Every problem in NP is polynomially reducible to D.The class of NP-complete problems is called NPC.                  NPCook’s theorem (1971): discover the first NP-complete        NP-completeproblem, CNF-satisfiability problem.Show a decision problem is NP-complete    Show that the problem is NP                                  P    Show that a known NP-complete problem can be    transformed to the problem in question in polynomial    time. (transitivity of polynomial reduction)Practical value of NP-completeness                                                                           20

Recommended

PDF
9. chapter 8 np hard and np complete problems
PDF
P, NP, NP-Complete, and NP-Hard
PPTX
Webinar : P, NP, NP-Hard , NP - Complete problems
PPTX
Automata theory - Push Down Automata (PDA)
PPTX
daa-unit-3-greedy method
PPTX
Knowledge representation and Predicate logic
PPTX
Hill climbing algorithm
PPTX
Adversarial Search
PDF
UNIT-V.pdf daa unit material 5 th unit ppt
PPTX
Graph coloring using backtracking
PPTX
8 queens problem using back tracking
PPT
Introduction to prolog
PPTX
Mathematical Analysis of Recursive Algorithm.
PDF
Topological Sort
PDF
AI 7 | Constraint Satisfaction Problem
PDF
Problem Characteristics in Artificial Intelligence
PPT
Greedy algorithms
PPT
Amortized Analysis of Algorithms
PDF
Hill climbing algorithm in artificial intelligence
PPTX
Np hard
PPTX
Longest Common Subsequence
PPT
Master method
PPTX
Computability - Tractable, Intractable and Non-computable Function
PPTX
NP Complete Problems
PPTX
AI Greedy and A-STAR Search
PPT
02 order of growth
PPT
Artificial intelligence and knowledge representation
PPTX
Producer consumer problem operating system
PPTX
NP completeness
PPT
Introduction to NP Completeness

More Related Content

PDF
9. chapter 8 np hard and np complete problems
PDF
P, NP, NP-Complete, and NP-Hard
PPTX
Webinar : P, NP, NP-Hard , NP - Complete problems
PPTX
Automata theory - Push Down Automata (PDA)
PPTX
daa-unit-3-greedy method
PPTX
Knowledge representation and Predicate logic
PPTX
Hill climbing algorithm
PPTX
Adversarial Search
9. chapter 8 np hard and np complete problems
P, NP, NP-Complete, and NP-Hard
Webinar : P, NP, NP-Hard , NP - Complete problems
Automata theory - Push Down Automata (PDA)
daa-unit-3-greedy method
Knowledge representation and Predicate logic
Hill climbing algorithm
Adversarial Search

What's hot

PDF
UNIT-V.pdf daa unit material 5 th unit ppt
PPTX
Graph coloring using backtracking
PPTX
8 queens problem using back tracking
PPT
Introduction to prolog
PPTX
Mathematical Analysis of Recursive Algorithm.
PDF
Topological Sort
PDF
AI 7 | Constraint Satisfaction Problem
PDF
Problem Characteristics in Artificial Intelligence
PPT
Greedy algorithms
PPT
Amortized Analysis of Algorithms
PDF
Hill climbing algorithm in artificial intelligence
PPTX
Np hard
PPTX
Longest Common Subsequence
PPT
Master method
PPTX
Computability - Tractable, Intractable and Non-computable Function
PPTX
NP Complete Problems
PPTX
AI Greedy and A-STAR Search
PPT
02 order of growth
PPT
Artificial intelligence and knowledge representation
PPTX
Producer consumer problem operating system
UNIT-V.pdf daa unit material 5 th unit ppt
Graph coloring using backtracking
8 queens problem using back tracking
Introduction to prolog
Mathematical Analysis of Recursive Algorithm.
Topological Sort
AI 7 | Constraint Satisfaction Problem
Problem Characteristics in Artificial Intelligence
Greedy algorithms
Amortized Analysis of Algorithms
Hill climbing algorithm in artificial intelligence
Np hard
Longest Common Subsequence
Master method
Computability - Tractable, Intractable and Non-computable Function
NP Complete Problems
AI Greedy and A-STAR Search
02 order of growth
Artificial intelligence and knowledge representation
Producer consumer problem operating system

Viewers also liked

PPTX
NP completeness
PPT
Introduction to NP Completeness
PPT
Np cooks theorem
PPTX
Deciability (automata presentation)
PPTX
Design and Analysis of Algorithms
PPTX
Branch and bound
 
PPTX
Ant colony optimization
PPTX
Tsp is NP-Complete
PDF
Undecidable Problem
PPT
Branch & bound
PPTX
Branch and bounding : Data structures
PDF
DOC
Branch and bound
PPTX
Travelling salesman problem ( Operation Research)
PDF
Decidability
PDF
Sienna 11 graphs
PDF
Tsp problem
PDF
Sienna 12 huffman
PPTX
Decidability of Finiteness of a Context Free Grammer
PDF
Um overview sobre temas em wp
 
NP completeness
Introduction to NP Completeness
Np cooks theorem
Deciability (automata presentation)
Design and Analysis of Algorithms
Branch and bound
 
Ant colony optimization
Tsp is NP-Complete
Undecidable Problem
Branch & bound
Branch and bounding : Data structures
Branch and bound
Travelling salesman problem ( Operation Research)
Decidability
Sienna 11 graphs
Tsp problem
Sienna 12 huffman
Decidability of Finiteness of a Context Free Grammer
Um overview sobre temas em wp
 

Similar to Algorithm chapter 10

PPT
Np completeness
PDF
UNIT -IV DAA.pdf
PPTX
PPTX
NP-Completeness-myppt.pptx
PPTX
Np Completeness
PPT
Np complete
PPT
UNIT-V.ppt
PPTX
PPTX
Teori pnp
PPT
NP-Completeewwwwwwwwwwwkkjjejjwjjjjjjjjj
PPTX
lec2cct computational cmplexity theory.pptx
PPTX
DAA_Hard_Problems_(4th_Sem).pptxxxxxxxxx
PPTX
Introduction to Computational Complexity Theory pptx
PPT
Confidence interval two tail tests-lower bounds upperbounds
PPT
Unit-IIUnit-IIUnit-IIUnit-IIUnit-IIUnit-IIUnit-V.ppt
PPTX
Design and analysis of algorithms unit 6 non deterministic polynomial
PDF
np hard, np complete, polynomial and non polynomial
PPT
CS 332 : Algorithms - Concept of NP Completeness
PPT
lecture 27
ODP
Theory of games
Np completeness
UNIT -IV DAA.pdf
NP-Completeness-myppt.pptx
Np Completeness
Np complete
UNIT-V.ppt
Teori pnp
NP-Completeewwwwwwwwwwwkkjjejjwjjjjjjjjj
lec2cct computational cmplexity theory.pptx
DAA_Hard_Problems_(4th_Sem).pptxxxxxxxxx
Introduction to Computational Complexity Theory pptx
Confidence interval two tail tests-lower bounds upperbounds
Unit-IIUnit-IIUnit-IIUnit-IIUnit-IIUnit-IIUnit-V.ppt
Design and analysis of algorithms unit 6 non deterministic polynomial
np hard, np complete, polynomial and non polynomial
CS 332 : Algorithms - Concept of NP Completeness
lecture 27
Theory of games

More from chidabdu

PDF
Algorithm chapter 6
PDF
Algorithm chapter 1
PPT
Unit 5 I/O organization
PDF
Algorithm chapter 8
PPT
Unit 3 basic processing unit
PDF
Algorithm chapter 5
PDF
Sienna 4 divideandconquer
PDF
Sienna 1 intro
PDF
Algorithm chapter 11
PDF
Sienna 3 bruteforce
PDF
Sienna 5 decreaseandconquer
PDF
Algorithm chapter 7
PDF
Sienna 10 dynamic
PDF
Sienna 2 analysis
PDF
Sienna 13 limitations
PDF
Sienna 8 countingsorts
PDF
Algorithm chapter 9
PDF
Sienna 7 heaps
PDF
Sienna 9 hashing
PDF
Sienna 6 bst
Algorithm chapter 6
Algorithm chapter 1
Unit 5 I/O organization
Algorithm chapter 8
Unit 3 basic processing unit
Algorithm chapter 5
Sienna 4 divideandconquer
Sienna 1 intro
Algorithm chapter 11
Sienna 3 bruteforce
Sienna 5 decreaseandconquer
Algorithm chapter 7
Sienna 10 dynamic
Sienna 2 analysis
Sienna 13 limitations
Sienna 8 countingsorts
Algorithm chapter 9
Sienna 7 heaps
Sienna 9 hashing
Sienna 6 bst

Recently uploaded

PDF
Supervised Machine Learning Approaches for Log-Based Anomaly Detection: A Cas...
PPTX
UFCD 0797 - SISTEMAS OPERATIVOS_Unidade Completa.pptx
PDF
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
PDF
KMWorld - KM & AI Bring Collectivity, Nostalgia, & Selectivity
PDF
Open Source Post-Quantum Cryptography - Matt Caswell
PDF
10 Best Automation QA Testing Software Tools in 2025.pdf
PDF
[BDD 2025 - Mobile Development] Crafting Immersive UI with E2E and AGSL Shade...
PDF
Top 10 AI Development Companies in UK 2025
PDF
Integrating AI with Meaningful Human Collaboration
PDF
Lets Build a Serverless Function with Kiro
PDF
[BDD 2025 - Full-Stack Development] PHP in AI Age: The Laravel Way. (Rizqy Hi...
PDF
Transcript: The partnership effect: Libraries and publishers on collaborating...
PDF
Running Non-Cloud-Native Databases in Cloud-Native Environments_ Challenges a...
PDF
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
PDF
The partnership effect: Libraries and publishers on collaborating and thrivin...
PDF
Oracle MySQL HeatWave - Complete - Version 3
PDF
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
PDF
Dev Dives: Build smarter agents with UiPath Agent Builder
PPTX
The power of Slack and MuleSoft | Bangalore MuleSoft Meetup #60
PDF
Cybersecurity Prevention and Detection: Unit 2
Supervised Machine Learning Approaches for Log-Based Anomaly Detection: A Cas...
UFCD 0797 - SISTEMAS OPERATIVOS_Unidade Completa.pptx
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
KMWorld - KM & AI Bring Collectivity, Nostalgia, & Selectivity
Open Source Post-Quantum Cryptography - Matt Caswell
10 Best Automation QA Testing Software Tools in 2025.pdf
[BDD 2025 - Mobile Development] Crafting Immersive UI with E2E and AGSL Shade...
Top 10 AI Development Companies in UK 2025
Integrating AI with Meaningful Human Collaboration
Lets Build a Serverless Function with Kiro
[BDD 2025 - Full-Stack Development] PHP in AI Age: The Laravel Way. (Rizqy Hi...
Transcript: The partnership effect: Libraries and publishers on collaborating...
Running Non-Cloud-Native Databases in Cloud-Native Environments_ Challenges a...
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
The partnership effect: Libraries and publishers on collaborating and thrivin...
Oracle MySQL HeatWave - Complete - Version 3
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
Dev Dives: Build smarter agents with UiPath Agent Builder
The power of Slack and MuleSoft | Bangalore MuleSoft Meetup #60
Cybersecurity Prevention and Detection: Unit 2

Algorithm chapter 10

  • 1.
    P, NP andNP-CompleteProblems
  • 2.
    Introduction An algorithmwith O(n3) complexity isn’t bad because it can still be run for fairly large inputs in a reasonable amount of time. In this chapter, we are concerned with problems with exponential complexity. Tractable and intractable problems Study the class of problems for which no reasonably fast algorithms have been found, but no one can prove that fast algorithms do not exist. 2
  • 3.
    Our Old Listof Problems Sorting Searching Shortest paths in a graph Minimum spanning tree Traveling salesman problem Knapsack problem Towers of Hanoi 3
  • 4.
    TractabilityAn algorithm solvesthe problem inpolynomial time if its worst-case timeefficiency belongs to O(p(n)) where p(n) is apolynomial of the problem’s input size n.Problems that can be solved in polynomialtime are called tractable.Problems that cannot be solved in polynomialtime are called intractable. 4
  • 5.
    Classifying a Problem’sComplexityIs there a polynomial-time algorithm that solves the problem?Possible answers: yes no because it can be proved that all algorithms take exponential time because it can be proved that no algorithm exists at all to solve this problem don’t know, but if such algorithms were to be found, then it would provide a means of solving many other problems in polynomial time 5
  • 6.
    Types of ProblemsOptimizationproblem: construct a solution thatmaximizes or minimizes some objective functionDecision problem: A question that has twopossible answers, yes and no. Example: Hamiltonian circles: A Hamiltonian circle in an undirected graph is a simple circle that passes through every vertex exactly once. The decision problem is: Does a given undirected graph have a Hamiltonian circle? 6
  • 7.
    Some More Problems(1)Many problems will have decision and optimization versions Traveling salesman problem Optimization problem: Given a weighted graph, find Hamiltonian cycle of minimum weight. Decision problem: Given a weighted graph and an integer k, is there a Hamiltonian cycle with total weight at most k? Knapsack : Suppose we have a knapsack of capacity W (a positive integer) and n objects with weights w1, …, wn, and values v1, …, vn (where w1, …, wn, and v1, …, vn are positive integers) Optimization problem: Find the largest total value of any subset of the objects that fits in the knapsack (and find a subset that achieves the maximum value) Decision problem: Given k, is there a subset of the objects that fits in the knapsack and has total value at least k? 7
  • 8.
    Some More Problems(2)Bin packing: Suppose we have an unlimited number of bins each ofcapacity one, and n objects with sizes s1, …, sn, where 0 ≤ si≤ 1( siare rational numbers) Optimization problem: Determine the smallest number of bins into which the objects can be packed(and find an optimal packing). Decision problem: Given, in addition to the inputs described, an integer k, do the objects fit in k bins?Graph coloring: coloring: assign a color to each vertex so that adjacent vertices are not assigned the same color. Chromatic number: the smallest number of colors needed to color G.We are given an undirected graph G = (V, E) to be colored. Optimization problem: Given G, determine the chromatic number . Decision problem: Given G and a positive integer k, is there a coloring of G using at most k colors? If so, G is said to be k-colorable. 8
  • 9.
    The class PP: the class of decision problems that can be solved in O(p(n)), where p(n) is a polynomial on n.Why use the existence of a polynomial time bound as the criterion? if not, very inefficient nice closure properties Given a computer program machine independent in a strong sense and an input to it, determine whether the program will halt on thatWhat is the solvability of a decision problem? input or continue working Solvable/decidable in polynomial time indefinitely on it. Solvable/decidable but intractable Unsolvable/undecidable problems: e.g., the halting problem No polynomial algorithm has been found, nor has the impossibility of such an algorithm been proved. 9
  • 10.
    The class NPInformally,NP is the class of decision problems for which a given proposed solution for a given input can be checked quickly(in polynomial time) to see if it really is a solution.Formally, NP: the class of decision problems that can be solved by nondeterministic polynomial (NP) algorithms A nondeterministic algorithm: a two-stage procedure that takes as its input an instance I of a decision problem and does the following “guessing” stage: An arbitrary string S is generated that can be thought of as a guess at a solution for the given instance (but may be complete gibberish as well) “verification” stage: A deterministic algorithm takes both I and S as its input and check if S is a solution to instance I, (outputs yes if s is a solution and outputs no or not halt at all otherwise) 10
  • 11.
    The class NPA nondeterministic algorithm solves a decision problem if and only if for every yes instance of the problem it returns yes on some execution. A nondeterministic algorithm is said to be polynomially bounded if there is a polynomial p such that for each input of size n for which the answer is yes, there is some execution of the algorithm that produces a yes output in at most p(n) steps. 11
  • 12.
    Example: graph coloringNondeterministic graph coloring First phase: generate a string s, a list of characters, c1c2…cq ,which the second phase interpret as a proposed coloring solution Second phase: interpret the above characters as colors to be assigned to the vertices ci vi 12
  • 13.
    Example: CNF Satisfiability The problem: Given a boolean expression expressed in conjunctive normal form(CNF), can we assign values true and false to variables to satisfy the CNF ? This problem is in NP. Nondeterministic algorithm: Guess truth assignment Make the formula true Check assignment to see if it satisfies CNF formula Example:(A⋁¬B ⋁ ¬C ) ⋀ (¬A ⋁ B) ⋀ (¬ B ⋁ D ⋁ E ) ⋀ (F ⋁ ¬ D) Truth assignments: A B CD E F1. 0 1 1 0 1 0 literals2. 1 0 0 0 0 13. 1 1 0 0 0 14. … 13
  • 14.
    The Relationship betweenP & NP (1)P ⊆ NP (I ∈ P I ∈ NP): Every decision problem solvable by a polynomial time deterministic algorithm is also solvable by a polynomial time nondeterministic algorithm. To see this, observe that any deterministic algorithm can be used as the checking stage of a nondeterministic algorithm. If I ∈ P, and A is any polynomial deterministic algorithm for I, we can obtain a polynomial nondeterministic algorithm for I merely by using A as the checking stage and ignoring the guess. Thus I ∈ P implies I ∈ NP 14
  • 15.
    The Relationship betweenP & NP (2) ?P = NP (NP ⊆ P?) Can the problems in NP be solved in polynomial time? A tentative view NP P 15
  • 16.
    NP-Completeness (1)NP-completeness isthe term used to describe decisionproblems that are the hardest ones in NP If there were a polynomial bounded algorithm for an NP- complete problem, then there would be a polynomial bounded algorithm for each problem in NP. Examples Hamiltonian cycle Traveling salesman Knapsack Bin packing Graph coloring Satisfiability 16
  • 17.
    Informal Definition ofNP-Completeness Informally, an NP-complete problem is a problem in NP that is as difficult as any other problem in this class, because by definition, any other problem in NP can be reduced to it in polynomial time. A decision problem D1 is said to be polynomially reducible to a decision problem D2 if there exists a function t that transforms instances of D1 to instances of D2 such that 1. t maps all yes instances of D1 to yes instances of D2 and all no instances of D1 to all no instances of D2. 2. t is computable by a polynomial-time algorithm.If D2 is polynomially solvable, then D1 can also be solved in polynomial time. 17
  • 18.
    An Example ofPolynomial Reductions Problem P: Given a sequence of Boolean values, does at least one of them have the value true? Problem Q: Given a sequence of integers, is the maximum of the integers positive? Transformation T: t(x1, x2, …, xn) = (y1, y2, …, yn), where yi = 1 if xi = true, and yi = 0 if xi = false. 18
  • 19.
    Another Example ofPolynomial ReductionsFor example a Hamiltonian circuit problem is polynomially reducible to the decision version of the traveling salesman problem. Hamiltonian circuit problem(HCP): Does a given undirected graph have a Hamiltonian cycle? Traveling salesman problem(TSP): Given a weighted graph and an integer k, is there a Hamiltonian cycle with total weight at most k? Transformation t: Map G, a given instance of the HCP to a weighted complete graph G’, an instance of the TSP by assigning 1 as the edge weight to each edge in G and adding an edge of weight 2 between any pair of nonadjacent vertices in G. Let k be n, the total vertex number in G. 19
  • 20.
    Formal Definition ofNP-CompletenessA decision problem D is said to be NP-complete if 1. It belongs to class NP. 2. Every problem in NP is polynomially reducible to D.The class of NP-complete problems is called NPC. NPCook’s theorem (1971): discover the first NP-complete NP-completeproblem, CNF-satisfiability problem.Show a decision problem is NP-complete Show that the problem is NP P Show that a known NP-complete problem can be transformed to the problem in question in polynomial time. (transitivity of polynomial reduction)Practical value of NP-completeness 20

[8]ページ先頭

©2009-2025 Movatter.jp