Docsity

Polynomial Time - Computability - Lecture Slide, Slides of Computer Science

Partial preview of the text

Download Polynomial Time - Computability - Lecture Slide and more Slides Computer Science in PDF only on Docsity!

1

The class P

2

Agenda

Running time

Big- O review

Time complexity classes  The class P Converting RAM programs to TM programs with polynomial loss of efficiency Decision problems encoding I/O problems  Factoring numbers Context free languages are in P  CYK algorithm

4

Running Time

Q: What the running time of the above?

0

1

rej acc

2

• R

1 R

0 R

1 R 0 R

0 R

1 R

5

Running Time

A: Assuming S = {0,1}, the running time is

T (n)=n+1` as can be seen on any input starting with 1. Even though the TM runs faster on 0{0,1}*, running time is defined in terms of the worst case. Crashes don’t affect this.

0

1

rej acc

2

• R

1 R

0 R

1 R 0 R

0 R

1 R

7

Strong Church-Turing Thesis?

As opposed to the standard Church-Turing

thesis for which there is overwhelming evidence, there is a great deal of current research trying to show that the strong version is false. In particular:

Possible Counterexample: Many conjecture

that no polynomial time algorithm exists for factoring numbers using a TM. But a polynomial time quantum algorithm exists (Peter Shor). Would mean that quantum computers invalidate Strong C-T thesis!

8

Big-O Notation

Nothing to say here.

Assume you learned in Discrete Math and

Data Structures.

10

Big- and Big-

Big- is just the reverse of big-O. I.e.

f (x ) = (g (x ))  g (x ) = O (f (x ))

So big- says that asymptotically f (x )

dominates g (x ).

Big- says that both functions dominate each- other so are asymptotically equivalent. I.e.

f (x ) = (g (x ))

f (x ) = O (g (x ))  f (x ) = (g (x ))

Synonym for f = (g): “ f is of order g ”

11

Useful facts

Any polynomial is big- of its largest

term

 EG: x 4 /100000 + 3x 3 + 5x 2 – 9 = (x 4 )

The sum of two functions is big- O of

the biggest

 EG: x 4 ln(x ) + x 5 = O (x 5 )

Non-zero constants are irrelevent:

 EG: 17x 4 ln(x ) = O (x 4 ln(x ))

13

Big-O, Big-, Big-.

A: Examples

  1. , (change of base formula)

ex

( x  sin x )( x^20  102 )

1 x

ln x

13  1 x lg 2 x x  sin x , xx , 13  x

xe

x ln x

x (ln x )^2

xx

14

Time Complexity Classes

Time complexity classes are the next

languages classes that we’ll study:

DEF: Suppose that g (n) is a real function.

The time complexity class TIME(g (n) ) consists of all languages which are decided by some TM with running time O(g (n)). Any such language is said to by of time complexity g (n).

16

Time Complexity

A: ALL! This particular decider for the

language has running time f (n) = n+ which is big-O of no.’s 1, 2 and 3. But the definition doesn’t say that must stick to any single implementation:

Q: How would you modify the TM to see

that accepted language is in TIME(1)?

0

1

rej acc

2

• R

0 R

1 R 0 R

0 R

1 R

17

Time Complexity

A: Accepted language is 10{0,1}*. So

just need to check first two bits as pictured below:

So now we see that the language is

accepted by a TM which runs in constant time.

0 1 2 acc

• R

0 R

1 R

1 R 0 R

19

From RAM to TM

in Polynomial Time

THM 1: Any RAM program which runs in O (f (n))

time can be simulated by a multi-tape TM which

runs in O (f (n)^3 ) time.

THM 2: Any multi-tape TM which runs in O (g (n))

time can be simulated by a one-tape TM which

runs in O (g (n)^2 ) time.

COR: Any RAM program which runs in O (f (n))

time can be simulated by a one-tape TM which

runs in O (f (n)^6 ) time.

Consequently, any algorithm that runs in polynomial time on your desktop, can be made to run in polynomial time on a TM.

20

From RAM to TM

in Polynomial Time

No proofs. Rather, give brief explanation:

A RAM consists of a “goto” style program and a memory made up of arbitrarily many integers called registers and each having an integer address. A single step of a RAM consists of doing

something to one of the registers^1. After k steps,

a RAM may have at most O ( k) active registers

each containing an integer of length O ( k). If we

keep these contents on one of the TM tapes, changing the state of the simulated RAM requires

reading all O ( k) registers each of size O ( k), so

O ( k 2 ) tape cells. Since k = O ( f ( n) ), and there

are f ( n) steps to simulate, g( n) = O ( f ( n)^3 ).Docsity.com