# Algorithm Design and Analysis

Topics: Computational complexity theory, Boolean satisfiability problem, NP-complete Pages: 16 (1889 words) Published: December 10, 2012
Algorithm Analysis and Design NP-Completeness
Pham Quang Dung

Hanoi, 2012

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

1 / 31

Outline

1

Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class

2

3

4

5

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

2 / 31

Class P: Problems that are solvable by polynomial-time algorithms (O(nk ) where n is the size of the input to the problem and k is some constant) Examples: Sorting Shortest path problems Minimum Spanning Tree problems Maximum Flow problems ...

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

3 / 31

Outline

1

Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class

2

3

4

5

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

4 / 31

Decision problems

Is n a prime number? Does an undirected graph contain a hamilton cycle? Satisﬁability: Given a boolean formula. Does there exist some assignment of the values 0 and 1 to its variables such that the value of the formula is 1? Subset sum problem: Given a set of integers S = {x1 , . . . , xn } and an integer T . Is there a subset of S whose sum is equal to T ?

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

5 / 31

Optimization problems

Each feasible solution is associated with a value Objective: Find a feasible solution with the best value Shortest path problem Minimum Spanning Tree problem Traveling Salemans Problem (TSP)

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

6 / 31

Outline

1

Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class

2

3

4

5

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

7 / 31

Class NP
Class NP:
Decision problems The correctness of a certiﬁcate can be veriﬁed in polynomial time P is the class of “easy to solve” problems and NP is the class of “easy to check” problems

Examples
Circuit satisﬁability (CIR-SAT) problem: Boolean circuit consists of logic gates (AND, OR, NOT), a set of input and one output interconnect to each other (as a directed graph). Is there an assignment of input such that the value of output produced by the circuit is 1? Hamilton Cycle (HAM-CYCLE) problem: Given an undirected graph G = (V , E ). Is there a simple cycle in G visiting each node of G exactly once?

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

8 / 31

Outline

1

Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class

2

3

4

5

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

9 / 31

Reductions

A decision problem P can be reduced to a decision problem Q if there exists an algorithm that transform an input x of P to a input f (x) of Q in polynomial time such that and x is “yes”-answer of P iﬀ f (x) is an “yes”-answer of Q Denote: P Q

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

10 / 31

Outline

1

Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class

2

3

4

5

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness

Hanoi, 2012

11 / 31

NP-complete class

A problem P is called NP-complete if:
P ∈ NP Q P, ∀Q ∈ NP

NP-complete is the class of hardest problems of NP If there exists an eﬃcient algorithm that solves in polynomial time a NP-complete problem, then all the problems of NP can be solved in polynomial time

Pham Quang Dung ()

Algorithm Analysis and Design NP-Completeness...