Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Polynomial Time - Automata and Complexity Theory - Lecture Slides, Slides of Theory of Automata

Some concept of Automata and Complexity Theory are Administrivia, Closure Properties, Context-Free Grammars, Decision Properties, Deterministic Finite Automata, Intractable Problems, More Undecidable Problems. Main points of this lecture are: Polynomial Time, Efficient Algorithms, Running Time, Algorithm, Input, Longer Inputs, Efficiency, Function, Running Time, Input Size

Typology: Slides

2012/2013

Uploaded on 04/29/2013

shamir_69
shamir_69 🇮🇳

5

(4)

66 documents

1 / 36

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Polynomial time
Docsity.com
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

Partial preview of the text

Download Polynomial Time - Automata and Complexity Theory - Lecture Slides and more Slides Theory of Automata in PDF only on Docsity!

Polynomial time

Efficient algorithms

  • The running time of an

algorithm depends on

the input

  • For longer inputs, we

allow more time

  • Efficiency is measured

as a function of input

size

ATM
PCP

Input representation

  • Since we measure efficiency in terms of input size, how

the input is represented will make a difference

  • For us, any “reasonable” representation will be okay

The number 17 17 10001 ( 17 in base two) 11111111111111111

OK OK NO

This graph

0000,0010,0001,

1 2

3 4

OK (2,3),(3,4) (^) OK

Measuring running time

• What does it mean when we say:

• One step in

all mean different things!

“This algorithm runs in 1000 steps”

java RAM machine Turing Machine if (x > 0) y = 5*y + x;

write r3; δ(q^3 , a) = (q^7 , b, R)

Efficiency and the Church-Turing thesis

  • The Church-Turing thesis says all these models

are equivalent in power…

… but not in running time!

java

RAM machine

Turing Machine

multitape TM

UNIVAC

The Cobham-Edmonds thesis

• However, there is an extension to the Church-

Turing thesis that says

For any realistic models of computation M 1 and

M 2 :

• So any task that takes time T on M 1 can be done in

time (say) T^2 or T^3 on M 2

M 1 can be simulated on M 2 with at most

polynomial slowdown

Example of efficient simulation

• Recall simulating multiple tapes on a single tape

M

0 1 0 …

0 1 …

1 0 0 …

S^0 1 0 #^0 1 #^1 00 # …

  

Γ = {0, 1, ☐, 0, 1,^ ^ ^ ☐ , #}

Running time of simulation

• Each move of the multiple tape TM might

require traversing the whole single tape

after t steps

O ( s ) steps of single tape TM s = rightmost cell ever visited

s ≤ 3 t + 4

1 step of 3-tape TM

t steps of 3-tape O ( ts ) = O ( t^2 ) single tape steps

multi-tape TM single tape TM

quadratic slowdown

Running time of nondeterministic

TM

• What about nondeterministic TMs?

• For ordinary TMs, the running time of M on

input x is the number of transitions M makes

before it halts

• But a nondeterministic TM can run for a

different time on different “computation

paths”

Example

• Definition of running time for nondeterministic

TM

qacc q 0 1/1R q 1 0/0R

what is the running time?

qrej

running time =

computation path: any possible sequence of transitions

max length of any computation path

Simulation slowdown for

For all k > 0 nondeterminism

For all possible strings a of length k Copy x to z. Simulate N on input z using a as choices If a specifies an invalid choice or simulation loops/rejects, abandon simulation. If N enters its accept state, accept and halt. If N rejected on all a s of length k , reject and halt.

running time of N is t simulation will halt when k = t

running time of simulation= (running time for specific a ) × (number of a s of length ≤ t ) = O( t ) × 2 O( t )^ = 2^ O( t )

Simulation slowdown

multi-tape java TM

RAM machine single tape TM

O ( t ) (^) O ( t ) O ( t^2 )

O ( t^2 ) O ( t ) O ( t )

nondeterministic TM

2 O( t )

Do nondeterministic TM violate the Cobham-Edmonds thesis?

Example

• Recall the scheduling problem

• Scheduling with nondeterminism:

CSC 3230 CSC 2110

CSC 3130 CSC 3160

Can you schedule final exams so that there are no conflicts?

Exams → vertices

Slots → colors

Conflicts → edges Y R B

schedule(int n, Edges edges) { for i := 1 to n: choose { c[i] := Y; } or { c[i] := R; } or { c[i] := B; } for all e in edges: if c[e.left] == c[e.right] reject; accept; }

Example

... but if we had it, we could schedule in linear

time!

schedule(int n, Edges edges) { for i := 1 to n: choose { c[i] := Y; } or { c[i] := R; } or { c[i] := B; } for all e in edges: if c[e.left] == c[e.right] reject; accept; }

In reality, programming languages don’t allow us to choose

We have to tell the computer how to make these choices

Nondeterminism does not seem like a realistic

feature of a programming language or computer