NP-Completeness and Undecidability: Subset Sum Problem and Halting Problem, Study notes of Algorithms and Programming

The np-completeness of the subset sum problem, providing a reduction from vertex cover to subset sum. It also explores the concept of undecidability, using the halting problem as an example. The halting problem is shown to be uncomputable, proving that there is no program that can be written to solve the termination problem.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-djv
koofers-user-djv 🇺🇸

9 documents

1 / 39

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Design and analysis of algorithms
Lecture 36 & 37
Edyta Szyma´
nska
CS3510 A, Fall 2005 p. 1/??
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download NP-Completeness and Undecidability: Subset Sum Problem and Halting Problem and more Study notes Algorithms and Programming in PDF only on Docsity!

Design and analysis of algorithms

Lecture 36 & 37

Edyta Szyma ´

nska

[email protected]

CS3510 A, Fall 2005 – p. 1/

Subset sum - numerical problem

Given a sequence of integers

a

,... , a 1

and a parametern

k,

decide whether there is a subset of integers whose sum isexactly

k

CS3510 A, Fall 2005 – p. 2/

Subset sum - numerical problem

Given a sequence of integers

a

,... , a 1

and a parametern

k,

decide whether there is a subset of integers whose sum isexactly

k

Formally, does there exist a subset

I^

1 ,... , n

}^

such that

∑ i∈I

ai

k

CS3510 A, Fall 2005 – p. 2/

Subset sum - numerical problem

Given a sequence of integers

a

,... , a 1

and a parametern

k,

decide whether there is a subset of integers whose sum isexactly

k

Formally, does there exist a subset

I^

1 ,... , n

}^

such that

∑ i∈I

ai

k

Theorem

Subset Sum is

NP-complete.

CS3510 A, Fall 2005 – p. 2/

From Vertex Cover to Subset Sum

Idea of the reduction:

Start from a graph

G

and a parameter

k.

Create a set of integers and a parameter

k

Prove that

G

has vertex cover of size

k

if and only if

there is a subset of the integers that sum to

k

′.^ CS3510 A, Fall 2005 – p. 3/

From Vertex Cover to Subset Sum

Let

G

be given with

V

2 ,... , n

}^

and some

k.

CS3510 A, Fall 2005 – p. 4/

From Vertex Cover to Subset Sum

Defining the integers:

CS3510 A, Fall 2005 – p. 5/

From Vertex Cover to Subset Sum

Defining the integers:

create a matrix with

n

m

rows corresponding to all

ai

’s and

bij

’s and

m

columns, corresponding to

bij

’s

plus one extra column

X

in

X

put a 1 for all

a

’s and a 0 otherwisei

in column

(ij

)^ put a 1 for

a

, ai

andj

bij

and 0 elsewhere.

define

k

′^ :=

k

·^

m 4

m

−^1 ∑ i=

i 4

CS3510 A, Fall 2005 – p. 5/

From Vertex Cover to Subset Sum

CS3510 A, Fall 2005 – p. 6/

From Vertex Cover to Subset Sum

CS3510 A, Fall 2005 – p. 6/

From Vertex Cover to Subset Sum

1 ′^ k

·^4

∑ i=

i^4

X^

CS3510 A, Fall 2005 – p. 6/

From Vertex Cover to Subset Sum

1 ′^ k

·^4

∑ i=

i^4

X^

CS3510 A, Fall 2005 – p. 6/

Reduction - correctness

From Covers to Subsets:

Suppose

vertex cover

C,

|C

|^ =

k.

Choose

a

’s andi

′ b ij

s^

as described.

When we sum up these integers (in base 4), then wehave a 2 in all digits except for column

X.

Then we

have a 1 in

X k

times.

Thus the sum is

k

CS3510 A, Fall 2005 – p. 7/

Reduction - correctness

From Subsets to Covers:

CS3510 A, Fall 2005 – p. 8/