NP-Completeness - PowerPoint PPT Presentation

About This Presentation
Title:

NP-Completeness

Description:

If i = (G, k) is an instance of the problem COLOR, then ... A problem whose instance set is a set of binary strings is called a concrete problem. ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 20
Provided by: ValuedGate2244
Learn more at: https://cs.gmu.edu
Category:

less

Transcript and Presenter's Notes

Title: NP-Completeness


1
NP-Completeness
  • CS 583 Fall 2006
  • Analysis of Algorithms

2
Outline
  • HW2/3 Status
  • Overview
  • Showing a problem to be NPC
  • Polynomial time
  • Abstract problems
  • Encodings
  • Verification in Polynomial Time
  • NP-completeness
  • Self-test
  • 34.1-2, 34.2-3
  • Final exam details

3
HW 2/3 Status
  • It is very likely that HW2 grades have been lost.
  • HW2 solutions are posted on the web.
  • Therefore, HW3 becomes mandatory to avoid
    losing 10 points.
  • The deadline is extended to Saturday, December 9
    (midnight).
  • The online submission needs to be e-mailed to the
    instructor.
  • The answers will posted on 12/10.
  • If HW2 grades are recovered before 12/16, they
    will be taken into account.

4
Overview
  • Three classes of problems
  • Class P consists of those problems that are
    solvable in polynomial time.
  • An algorithm runs in O(nk) for some constant k,
    where n is the size of the input.
  • Class NP consists of problems that are
    verifiable in polynomial time.
  • It can be verified in polynomial time that a
    given solution is feasible.
  • A problem is in the class NPC if it is in NP, and
    is as hard as any other problem in NP.
  • If any NP-complete problem can be solved in
    polynomial time, then every problem in NP has a
    polynomial time algorithm.
  • Most computer scientists believe NPC problems are
    intractable, i.e. P ? NP.

5
Showing a Problem to be NPC
  • Decision problems versus optimization problems.
  • Many problems of interest are optimization
    problems
  • Each feasible solution has an associated value,
    and we wish to find the one with the best value.
  • For example, the graph coloring problem use the
    least number of colors, so that no two adjacent
    vertices are colored the same.
  • NP-completeness applies to decision problems
  • The answer to a problem is yes or no.
  • For example, the graph coloring decision problem
    can a graph be colored with k colors?
  • An optimization problem can be cast to a decision
    problem.
  • The decision problem is easier as once an
    optimization problem is solved, its related
    decision problem is solved as well.

6
Reductions
  • We show that one decision problem is no easier or
    harder than another one.
  • Suppose we have a decision problem A that we wish
    to solve in polynomial time.
  • Assume we have a decision problem B that we can
    solve in polynomial time.
  • Develop a procedure that converts an instance
    (input) ? of A into instance ? of B as follows.
  • The transformation takes polynomial time.
  • The answers are the same the answer for ? is
    yes if and only if the answer for ? is also
    yes.

7
Reductions (cont.)
  • Such procedure is called a reduction algorithm as
    it allows solving A in polynomial time
  • Given an instance ? of A, use a polynomial-time
    reduction algorithm to transform it to an
    instance ? of B.
  • Run B in polynomial time on input ?.
  • Use the answer for ? as the answer for ?.
  • It can be shown that if it is proven that A is
    intractable, then B cannot be solved in
    polynomial time as well.
  • Proof by contradiction.

8
A First NPC Problem
  • The technique of reduction relies on having a
    problem known to be NP-complete.
  • Hence we need to start with some NPC problem.
  • The first such problem we use is the
    circuit-satisfiability problem
  • Given a boolean combinational circuit composed of
    AND, OR, and NOT gates,
  • We wish to know if theres any set of boolean
    inputs to this circuit that causes its output to
    be 1.

9
Polynomial time
  • The polynomial time problems are considered
    tractable for the following reasons
  • A problem that runs in ?(n100) is practically
    intractable. However,
  • In practice there are very few such problems.
  • When a problem running in ?(n100) is solved, it
    is likely that much better algorithms are
    discovered.
  • A problem that can be solved in polynomial time
    in one model, can be solved in P time in another.
  • Parallel algorithms.
  • Class P has closure properties.
  • An algorithm composed of P-time algorithms is
    also polynomial.

10
Abstract Problems
  • An abstract problem Q is a binary relation on a
    set I of problem instances, and a set S of
    solutions
  • Q I ? S, e.g., (i1, s1) ? Q, where i1 ? I, s1 ?
    S.
  • Decision problems have a yes/no solution
  • S 0, 1
  • Example graph coloring decision problem COLOR
  • If i (G, k) is an instance of the problem
    COLOR, then
  • COLOR(i) 1 (yes) if graph G can be colored with
    k colors
  • COLOR(i) 0 (no) otherwise
  • Recall that more practical optimization problems
    can be recast as decision problems.

11
Concrete Problems
  • An encoding of a set S of abstract objects is a
    mapping e from S to the set of binary strings.
  • Example natural numbers (set N0,1,2,...) can
    be represented as binary numbers
  • e(3) 11, e(4) 100, ... , e(17) 10001
  • An algorithm that solves some abstract decision
    problem takes an encoding of a problem instance
    as input.
  • A problem whose instance set is a set of binary
    strings is called a concrete problem.
  • An algorithm solves a concrete problem in O(T(n))
    time, where n i
  • A problem is polynomial-time solvable if T(n)
    nk for some constant k.
  • The complexity class P is a set of concrete
    decision problems that are polynomial-time
    solvable.

12
Formal-Language Framework
  • The machinery of formal-language theory is very
    convenient for decision problems.
  • An alphabet ? is a finite set of symbols.
  • A language L over ? is any set of strings made up
    of symbols from ?.
  • For example, ? 0,1, L 10,11,101, ...
    prime numbers
  • An empty string is denoted by ?,
  • An empty language is denoted by ?.
  • The language of all strings over ? is denoted ?.
  • For example, ? 0,1, ? ?, 0 , 1, 00, 10,
    11, 101, ... the set of all binary strings.

13
Formal-Language Framework (cont.)
  • Operations on languages
  • Union and intersection follow directly from set
    operations.
  • The complement of L is ? L ? - L.
  • The concatenation of two languages L1 and L2 is
    the language
  • L x1x2 x1 ? L1 and x2 ? L2
  • The closure, or Kleene star of language L is
  • L ? ? L ? L2 ? L3 ? ...
  • Hence, the set of instances for any decision
    problem Q is simply the set ?, where ? 0,1.

14
Formal-Language Framework (cont.)
  • Q is a language L over ? 0,1, where
  • L x ? ? Q(x) 1
  • Expressing the relation between decision problems
    and algorithms.
  • An algorithm A accepts a string x ? 0,1 if
  • given input x, the algorithm outputs A(x) 1.
  • An algorithm rejects x if A(x) 0.
  • The language accepted by A is
  • L x ? 0,1 A(x) 1
  • A language L is decided by A if
  • every binary string in L is accepted by A, and
  • every binary string not in L is rejected by A.

15
Formal-Language Framework (cont.)
  • A language L is accepted in polynomial time by
    algorithm A if
  • it is accepted by A, and
  • there is a constant k such that for any x ? L,
    x n it accepts x in O(nk).
  • A language L is decided in polynomial time if
  • there is a constant k such that for any x ?
    0,1, x n, A correctly decides whether x ?
    L in O(nk).
  • Thus, to accept a language, an algorithm only
    needs to consider strings in L, but to decide it,
    it needs to consider every string in 0,1.
  • The complexity class P
  • P L ? 0,1 there exists an algorithm A
    that decides L in polynomial time

16
Hamiltonian Cycle Problem
  • Hamiltonian cycle
  • A hamiltonian cycle of a graph G(V,E) is a
    simple cycle that contains all vertices in V.
  • A graph that contains a hamiltonian cycle is
    called hamiltonian.
  • The Hamiltonian cycle problem defined in a formal
    language
  • HAM-CYCLE ltGgt G is a hamiltonian graph
  • Brute-force algorithm
  • Take each permutation of vertices and check if
    its a hamiltonian graph.
  • Running time
  • Assume the encoding is its adjacency matrix of
    size n.
  • The number of vertices m ?(n1/2).
  • There are m! possible permutations of vertices.
  • The running time of such algorithm is ?(m!)
    ?(n1/2!) ?(2n1/2) not polynomial!

17
Verification Algorithm
  • When a certain permutation of vertices is given,
    it can be verified if its a hamiltonian cycle in
    O(n2) time.
  • A verification algorithm is a two-argument
    algorithm A
  • One argument is an input string x.
  • The other argument is a binary string y called a
    certificate.
  • A verifies an input x if there exists a
    certificate y such that
  • A(x,y) 1
  • The language verified by A is
  • L x ? 0,1 there exists y ? 0,1 such
    that A(x,y) 1
  • A verifies L if for any string x ? L, there is a
    certificate y that A can use to prove that x ? L.
  • In the HAM-CYCLE problem, the certificate is the
    list of vertices in some hamiltonian cycle.
  • If the graph is hamiltonian, the cycle is
    sufficient to verify the fact.
  • If it is not hamiltonian, no such certificate
    exists.

18
The Complexity Class NP
  • NP is the class of languages that can be verified
    by a polynomial-time algorithm A(x,y)
  • L x ? 0,1 there exists a certificate y
    with y O(xc) such that c is constant and
    A(x,y) 1
  • We say that algorithm A verifies language L in
    polynomial time.
  • If L? P, then L? NP
  • If there is a polynomial time algorithm to decide
    L, it can be converted to a verification
    algorithm to ignore the certificate.
  • Hence P ? NP.
  • It is unknown if P NP
  • The class of NP-complete algorithms makes this
    question even more intriguing
  • If one NPC algorithm can be solved in polynomial
    time, then every problem in NP has a polynomial
    time solution!

19
Final Exam
  • Taking the exam
  • The exam will be available to take in a
    classroom.
  • The exam will be available online on case-by-case
    basis only.
  • The exceptions will be granted based on good
    cause.
  • The online version will be distributed by e-mail.
  • The NEW session will be open during the exam for
    student questions.
  • The student evaluations will be taken before the
    exam.
  • Exam details
  • It is an open everything exam.
  • The duration is 2.5 hours, -- from 745 to 1015.
  • It consists of 4 main problems (10 points each),
    and 2 bonus questions (2 points each).
  • The exam covers the contents of all classes,
    although it will contain more questions from the
    second half of the course (after the midterm
    exam).
  • Overall grading
  • A 90 points
  • B 85 B 80 B- 75
  • C 65 D 60
Write a Comment
User Comments (0)
About PowerShow.com