1 / 33

# Time Complexity - PowerPoint PPT Presentation

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. Example:. Algorithm to accept a string :. Use a two-tape Turing machine Copy the on the second tape Compare the and. Time needed:.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

## PowerPoint Slideshow about ' Time Complexity' - hamish-medina

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

• We use a multitape Turing machine

• We count the number of steps until

• a string is accepted

• We use the O(k) notation

COMP 335

Algorithm to accept a string :

• Use a two-tape Turing machine

• Copy the on the second tape

• Compare the and

COMP 335

• Copy the on the second tape

• Compare the and

Total time:

COMP 335

time needed for acceptance:

COMP 335

A Deterministic Turing Machine

accepts each string of length

in time

COMP 335

for any time function:

Examples:

COMP 335

Example: The membership problem

for context free languages

(CYK - algorithm)

Polynomial time

COMP 335

COMP 335

Represent tractable algorithms:

For small we can compute the

result fast

COMP 335

for all

• Polynomial time

• All tractable problems

COMP 335

COMP 335

Represent intractable algorithms:

Some problem instances

may take centuries to solve

COMP 335

Example: the Hamiltonian Problem

s

t

Question: is there a Hamiltonian path

from s to t?

COMP 335

t

YES!

COMP 335

A solution: search exhaustively all paths

L = {<G,s,t>: there is a Hamiltonian path

in G from s to t}

Exponential time

Intractable problem

COMP 335

Example: The Satisfiability Problem

Boolean expressions in

Conjunctive Normal Form:

Variables

Question: is expression satisfiable?

COMP 335

Satisfiable:

COMP 335

Not satisfiable

COMP 335

exponential

Algorithm:

search exhaustively all the possible

binary values of the variables

COMP 335

Language class:

A Non-Deterministic Turing Machine

accepts each string of length

in time

COMP 335

Non-Deterministic Algorithm

to accept a string :

• Use a two-tape Turing machine

• Guess the middle of the string

• and copy on the second tape

• Compare the two tapes

COMP 335

• Use a two-tape Turing machine

• Guess the middle of the string

• and copy on the second tape

• Compare the two tapes

Total time:

COMP 335

for any time function:

Examples:

COMP 335

for all

Non-Deterministic Polynomial time

COMP 335

Example:

Non-Deterministic algorithm:

• Guess an assignment of the variables

• Check if this is a satisfying assignment

COMP 335

• Guess an assignment of the variables

• Check if this is a satisfying assignment

Total time:

COMP 335

Deterministic

Polynomial

Non-Deterministic

Polynomial

COMP 335

WE DO NOT KNOW THE ANSWER

COMP 335

Example: Does the Satisfiability problem

have a polynomial time

deterministic algorithm?

WE DO NOT KNOW THE ANSWER

COMP 335