NP Completeness Prof. Dr. Debora Weber-Wulff Winter term 2006/07 - - PowerPoint PPT Presentation

np completeness
SMART_READER_LITE
LIVE PREVIEW

NP Completeness Prof. Dr. Debora Weber-Wulff Winter term 2006/07 - - PowerPoint PPT Presentation

NP Completeness Prof. Dr. Debora Weber-Wulff Winter term 2006/07 Inefficiency and Intractability From the book: Algorithmics, the Spirit of Computing, David Harel. Addison-Wesley, 1992 Complexity Paradox? Complicated algorithms often


slide-1
SLIDE 1

NP Completeness

  • Prof. Dr. Debora Weber-Wulff

Winter term 2006/07

slide-2
SLIDE 2

Inefficiency and Intractability

  • From the book:

Algorithmics, the Spirit of Computing, David Harel. Addison-Wesley, 1992

slide-3
SLIDE 3

Complexity Paradox?

  • Complicated algorithms often have

a lower complexity than the simple, obvious solutions

  • But we have fast computers, so

who cares, anyway?

slide-4
SLIDE 4

Unfortunately,....

  • There exist problems that cannot

be solved in even quadratic time.

  • There are problems for which a

solution just does not exist.

  • There are problems that also need

exponential space!

slide-5
SLIDE 5

Towers of Hanoi

  • What was the complexity?

2 N -1

slide-6
SLIDE 6

Towers of Hanoi

  • Even moving a million rings a

second, for 64 rings you need half a million years to complete the puzzle.

  • If you need 10 sec / ring, you need

five trillion years!

  • This is provably the lower bound.
slide-7
SLIDE 7

Decision problems

  • Don't do anything but answer

"yes" or "no"

  • Purpose is to decide if a property

holds for the input

slide-8
SLIDE 8

The Monkey Puzzle

  • Can 9 of these be laid in a 3x3?
slide-9
SLIDE 9

General Problem

  • Given N cards, N= M*M, each edge

decorated with an upper or lower half of a figure.

  • Can the cards be laid out in an

M*M pattern so that the figures of adjoining cards match?

slide-10
SLIDE 10

Brute Force

  • For all possible cards and all

possible orientations of the cards, lay them out in M*M

  • Return "yes" if this is a valid

layout, otherwise continue

  • When all cases have been tested,

return "no".

slide-11
SLIDE 11

Complexity?

  • Disregarding the orientation:

O(N!)

  • With the orientation:

O(4*N!) which is still O (N!)

  • O(9) = 362 800,

O(4*9) = 1 451 520

slide-12
SLIDE 12

That's not so bad

  • But what about N=25?
  • 25! is a number with 26 digits, if

you could test a million arrangements a second, you would need over 490 billion years to check it!

slide-13
SLIDE 13

Isn't there a clever solution?

  • You can stop as soon as you find

that the pattern is illegal

  • This does not really change the

complexity.

  • There is no known way to solve

this problem in Polynomial time

slide-14
SLIDE 14

Reasonable vs. Unreasonable Time

  • Factorial grows faster than

exponential, even though N1000 is still greater than N! for many values of N.

  • For example at N=1165, the

factorial oversteps the exponential function.

slide-15
SLIDE 15

Good vs. Bad functions

  • Good functions run in Polynomial

time: Nk + c1*Nk-1 + .... + ck-1

  • We say they have an upper bound
  • f Nk
  • Everything else is

superpolynomial

slide-16
SLIDE 16

Superpolynomial

  • logarithmic, linear, quadratic,

cubic – all are polynomial

  • 1.001N + N6, 5N, NN, N! are

exponential or worse

  • N log

2 N are superpolynomial but not

exponential

slide-17
SLIDE 17

Growth rates

slide-18
SLIDE 18

Tractable

  • Problems that are solvable in

polynomial time are called tractable

  • Problems that are solvable in

superpolynomial time are called intractable

slide-19
SLIDE 19

Intractable Problems

  • Need impractically large amounts
  • f time even on relatively small

inputs

  • And there are lots of them.... close

to 1000 different problems.

slide-20
SLIDE 20

Proof?

  • Even worse, we have not been able

to prove that no polynomial solution exists!

  • We just don't know!
  • This class of problems is called

NPC, NP-complete problems, and it is growing

slide-21
SLIDE 21

NP-Complete

  • Strangely enough, have a linear

lower bound, but an exponential upper bound.

slide-22
SLIDE 22

NP-Complete problems

  • Two-dimensional Arrangment
  • Path-finding (TSP)
  • Scheduling and Matching
  • Determining Logical Truth
  • Coloring Maps and Graphs
slide-23
SLIDE 23

Short Certificates

  • Even though they are difficult to

find, once we have a solution "yes", we can easily prove that it solves the problem.

  • We call this the short certificate or

magic coin

slide-24
SLIDE 24

Short Certificates

  • are often linear
  • For example, it is hard to find a

Hamiltonian path, but easy to test that it is indeed one.

slide-25
SLIDE 25

Magic Coin

  • We begin with a partial solution

and extend it.

  • If we could flip a magic coin to

determine whether the next step leads to a yes or no, we could win

  • This is called non-determinism
slide-26
SLIDE 26

NPC

  • Non-deterministic Polynomial are

those problems which are intractable, but have a non- deterministic polynomial certificate

  • C stands for Complete
slide-27
SLIDE 27

Completeness

  • NPC problems are those which can

be solved if we find a polynomial solution for even one!!

  • Either all NPC problems are

tractable, or they are all intractable, but we just don't know!

slide-28
SLIDE 28

Polynomial-time Reduction

  • It is possible in Polynomial time to

reduce one NPC-Problem to another one.

  • TSP can be formulated as

Hamiltonian Path.

slide-29
SLIDE 29

P = NP?

  • This is one of the big research

questions!

  • Open since it was posed in 1971
slide-30
SLIDE 30

Testing for Primeness

  • Is a number not prime?
  • If the answer is yes, we deliver a

short certificate, the two factors, which can be readily multiplied

  • So this is NP, but we do not know

if it is NP complete, or even P!

slide-31
SLIDE 31

Testing for Primeness

  • Is this number prime?
  • No short certificate, so not
  • bvious, that it is in NP (but this

has since been proven)

  • But we do not know if this is NP-

complete or not!!!

slide-32
SLIDE 32

Intractable and not NPC

  • Towers of Hanoi
  • Roadblock
  • Satisfiablity – reasoning about

propositional calculus

slide-33
SLIDE 33

Can it get worse?

  • Of course – double or triple

exponential!

  • Satisfiability in Presburger

Arithmetic

slide-34
SLIDE 34

Complexity Classes

slide-35
SLIDE 35

Imperfect Solutions

  • Sometimes we are happy with a

solution that is not optimal – an approximation

  • Often heuristic (rule of thumb)

methods yield good results, for example with TSP.

slide-36
SLIDE 36

No amount of cleverness can help when your problem is NP!