SmithLogo

CSC 250

Theory of Computation

Smith Computer Science



Lecture Notes 29: Computational Complexity


Outline

This class we'll discuss:




Recap: Is this problem doable?













The problem: Is there some way to set these boolean values so the whole thing evaluates to TRUE?



The problem: Pattern matching



The problem: More powerful pattern matching



Restricted notion of “computation”

  1. no memory
  2. only get to read once
  3. exactly the same class of languages as REs




Very general notion of computation
  1. unlimited storage
  2. multiple passes over the input
  3. can compute for as long as you like (doesn’t even have to be guaranteed to stop)
  4. Large, sweeping language classes: turing decidable, turing recognizable = enumerable












Here’s the thing: just knowing that it is POSSIBLE to compute a solution to a problem doesn’t give us any information about how difficult that problem is. The only information we have is… it is not impossible.

That level of resolution is not great.




What else would be useful to know (in addition to the fact that a problem is solvable)?









Complexity









(Wait; then Click)

HALF








(Wait; then Click)

Depends on the particular input.








How long will it take for this input?

How about for "01", "0011", "00001111" ... ?
























(Wait; then Click)

Initial check (steps 1 and 2) takes 2n steps (n to read, and n to get back)
We could have at most n/2 passes over step 3 (because we mark off two letters each time)
And to make things easier, let’s say we read the whole string each pass
\(2n + (n/2)*2n = 2n + n^2 \) steps to accept




Is there a better estimate?
(Wait; then Click)

\(\mathcal{O}( n^2 ) \)




























Try modifying the algorithm with a more efficient one



(Wait; then Click)

3. Copy all the 0s to a second tape
4. Move the two heads together, counting off a 1 and a 0 each step
5. If you hit the end of both tapes at the same time ACCEPT, otherwise REJECT”


2n steps for lines 1 and 2
n steps for line 3
n steps for line 4
\(= 4n = \mathcal{O}(n) \)































































Homework


[Due for everyone]


[Optional]
TODO