An Overview of Computational Complexity - - PowerPoint PPT Presentation

an overview of computational complexity
SMART_READER_LITE
LIVE PREVIEW

An Overview of Computational Complexity - - PowerPoint PPT Presentation

An Overview of Computational Complexity kazim@fouladi.ir


slide-1
SLIDE 1

رتويپماك‌و‌قرب‌يسدنهم‌ي‌هدكشناداه‌نيشام‌و‌اه‌نابز‌ي‌هيرظن

يتابساحم‌يگديچيپ‌رب‌يرورم

An Overview of Computational Complexity

يدلبوف‌مظاك kazim@fouladi.ir رتويپماك‌و‌قرب‌يسدنهم‌ي‌هدكشناد نارهت‌هاگشناد

مهدراهچ‌لصف

slide-2
SLIDE 2

2

Computational Complexity

slide-3
SLIDE 3

3

Time Complexity: Space Complexity: The number of steps during a computation Space used during a computation

slide-4
SLIDE 4

4

Time Complexity

  • We use a multitape Turing machine
  • We count the number of steps until

a string is accepted

  • We use the O(k) notation
slide-5
SLIDE 5

5

Example:

} : {   n b a L

n n

Algorithm to accept a string :

w

  • Use a two-tape Turing machine
  • Copy the on the second tape
  • Compare the and

a a b

slide-6
SLIDE 6

6

|) (| w O

  • Copy the on the second tape
  • Compare the and

a a b

Time needed:

|) (| w O

Total time:

|) (| w O } : {   n b a L

n n

slide-7
SLIDE 7

7

For string of length time needed for acceptance:

} : {   n b a L

n n

n ) (n O

slide-8
SLIDE 8

8

Language class:

) (n DTIME

A Deterministic Turing Machine accepts each string of length in time

) (n DTIME

1

L

2

L

3

L ) (n O n

slide-9
SLIDE 9

9

) (n DTIME } : {  n b a

n n

} {ww

slide-10
SLIDE 10

10

In a similar way we define the class

)) ( ( n T DTIME ) (n T

for any time function: Examples:

),... ( ), (

3 2

n DTIME n DTIME

slide-11
SLIDE 11

11

Example: The membership problem for context free languages

} grammar by generated is : { G w w L  ) ( 3 n DTIME L

(CYK - algorithm)

Polynomial time

slide-12
SLIDE 12

12

Theorem:

) ( k n DTIME ) (

1  k

n DTIME

1

( ) ( )

k k

DTIME n DTIME n

slide-13
SLIDE 13

13

Polynomial time algorithms:

) ( k n DTIME

Represent tractable algorithms: For small we can compute the result fast

k

slide-14
SLIDE 14

14

) ( k n DTIME P  

for all k The class P

  • All tractable problems
  • Polynomial time
slide-15
SLIDE 15

15

P

CYK-algorithm

} {

n nb

a

} {ww

slide-16
SLIDE 16

16

Exponential time algorithms:

) 2 ( n DTIME

Represent intractable algorithms: Some problem instances may take centuries to solve

slide-17
SLIDE 17

17

Example: the Traveling Salesperson Problem Question: what is the shortest route that connects all cities?

5 3 2 1 8 10 2 4 3 6

slide-18
SLIDE 18

18

Question: what is the shortest route that connects all cities?

5 3 2 1 8 10 2 4 3 6

slide-19
SLIDE 19

19

Example: the Hamiltonian Problem Question: is there a Hamiltonian path from s to t? s t

slide-20
SLIDE 20

20

s t YES!

slide-21
SLIDE 21

21

) 2 ( ) ! (

n

DTIME n DTIME L  

Exponential time Intractable problem A solution: search exhaustively all paths L = {<G,s,t>: there is a Hamiltonian path in G from s to t}

slide-22
SLIDE 22

22

Example: The Satisfiability Problem Boolean expressions in Conjunctive Normal Form:

k

t t t t     

3 2 1 p i

x x x x t      

3 2 1

Variables Question: is expression satisfiable?

slide-23
SLIDE 23

23

) ( ) (

3 1 2 1

x x x x   

Satisfiable:

1 , 1 ,

3 2 1

   x x x 1 ) ( ) (

3 1 2 1

    x x x x

Example:

slide-24
SLIDE 24

24

2 1 2 1

) ( x x x x   

Not satisfiable Example:

slide-25
SLIDE 25

25

e} satisfiabl is expression : { w w L  ) 2 ( n DTIME L

For variables:

n

Algorithm: search exhaustively all the possible binary values of the variables exponential

slide-26
SLIDE 26

26

Non-Determinism

Language class:

) (n NTIME

A Non-Deterministic Turing Machine accepts each string of length in time

) (n NTIME

1

L

2

L

3

L ) (n O n

slide-27
SLIDE 27

27

Example:

} {ww L 

Non-Deterministic Algorithm to accept a string :

ww

  • Use a two-tape Turing machine
  • Guess the middle of the string

and copy on the second tape

  • Compare the two tapes

w

slide-28
SLIDE 28

28

|) (| w O

Time needed:

|) (| w O

Total time:

|) (| w O } {ww L 

  • Use a two-tape Turing machine
  • Guess the middle of the string

and copy on the second tape

  • Compare the two tapes

w

slide-29
SLIDE 29

29

) (n NTIME } {ww L 

slide-30
SLIDE 30

30

In a similar way we define the class

)) ( ( n T NTIME ) (n T

for any time function: Examples:

),... ( ), (

3 2

n NTIME n NTIME

slide-31
SLIDE 31

31

Non-Deterministic Polynomial time algorithms:

) ( k n NTIME L

slide-32
SLIDE 32

32

) ( k n NTIME P  

for all k The class NP Non-Deterministic Polynomial time

NP

slide-33
SLIDE 33

33

Example: The satisfiability problem Non-Deterministic algorithm:

  • Guess an assignment of the variables

e} satisfiabl is expression : { w w L 

  • Check if this is a satisfying assignment
slide-34
SLIDE 34

34

Time for variables:

n ) (n O

e} satisfiabl is expression : { w w L 

Total time:

  • Guess an assignment of the variables
  • Check if this is a satisfying assignment

) (n O ) (n O

slide-35
SLIDE 35

35

e} satisfiabl is expression : { w w L  NP L

The satisfiability problem is an - Problem

NP

slide-36
SLIDE 36

36

Observation:

NP P 

Deterministic Polynomial Non-Deterministic Polynomial

slide-37
SLIDE 37

37

Open Problem:

? NP P 

WE DO NOT KNOW THE ANSWER

slide-38
SLIDE 38

38

Example: Does the Satisfiability problem have a polynomial time deterministic algorithm? WE DO NOT KNOW THE ANSWER Open Problem:

? NP P 

slide-39
SLIDE 39

39

NP-Completeness

A problem is NP-complete if:

  • It is in NP
  • Every NP problem is reduced to it

(in polynomial time)

slide-40
SLIDE 40

40

Polynomial Time Reductions

Polynomial Computable function : f For any computes in polynomial time

) (w f

w

slide-41
SLIDE 41

41

Language A is polynomial time reducible to language B if there is a polynomial computable function such that:

f B w f A w    ) (

slide-42
SLIDE 42

42

Suppose that is polynomial reducible to . If then . Theorem:

P B A B P A

Proof: Machine to accept in polynomial time:

A

On input :

w

  • 1. Compute

) (w f

Let be the machine to accept B

M

  • 2. Run on input

) (w f

M

slide-43
SLIDE 43

43

3CNF formula:

) ( ) ( ) ( ) (

6 5 4 4 6 3 6 5 3 3 2 1

x x x x x x x x x x x x           

Each clause has three literals 3SAT ={ : is a satisfiable 3CNF formula}

w w

Language:

slide-44
SLIDE 44

44

Clique: A 5-clique CLIQUE = { : contains a -clique}

  k G,

G

k

slide-45
SLIDE 45

45

Theorem: 3SAT is polynomial time reducible to CLIQUE Proof: give a polynomial time reduction

  • f one problem to the other
slide-46
SLIDE 46

46

) ( ) ( ) (

3 2 1 2 2 1 2 1 1

x x x x x x x x x        

1

x

1

x

2

x

1

x

2

x

2

x

1

x

2

x

3

x

slide-47
SLIDE 47

47

) ( ) ( ) (

3 2 1 2 2 1 2 1 1

x x x x x x x x x        

1

x

1

x

2

x

1

x

2

x

2

x

1

x

2

x

3

x 1 1

3 2 1

   x x x

slide-48
SLIDE 48

48

Cook’s Theorem: The satisfiability problem is NP-complete Proof: Convert a Non-Deterministic Turing Machine to a Boolean expression in conjunctive normal form

slide-49
SLIDE 49

49

Other NP-Complete Problems:

  • The Traveling Salesperson Problem
  • Vertex cover
  • Hamiltonian Path

All the above are reduced to the satisfiability problem

slide-50
SLIDE 50

50

Observation: If we can solve any NP-complete problem in Deterministic Polynomial Time (P time) then we know:

NP P 

slide-51
SLIDE 51

51

Observation: If we prove that we cannot solve an NP-complete problem in Deterministic Polynomial Time (P time) then we know:

NP P 

slide-52
SLIDE 52

52

Observations: It is unlikely that NP-complete problems are in P The NP-complete problems have exponential time algorithms Approximations of these problems are in P