

































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This course is about: Formal Languages, Automata, Complexity. Complexity, Decidable Languages, Time, Space, Time Complexity, Worst-case Analysis, Average-case Analysis, Asymptotic Analysis, Reality Check, Small-o Notation, Complexity Classes, Multitape Turing Machines, Nondeterministic TMs, Brute Force Algorithm, Hamiltonian Path Problem
Typology: Slides
1 / 41
This page cannot be seen from the preview
Don't miss anything!


































COMPLEXITY
Assume that a problem (language) is decidable. Does that mean we can realistically solve it?
NO, not always. It can require to much of time or memory resources.
Complexity Theory aims to make general conclusions of the resource requirements of decidable problems (languages).
Henceforth, we only consider decidable languages and deciders. Our computational model is a Turing Machine. Time: the number of computation steps a TM machine makes to decide on an input of size n. Space: the maximum number of tape cells a TM machine takes to decide on a input of size n.
The number of steps in measured as a function of n - the size of the string representing the input. In worst-case analysis, we consider the longest running time of all inputs of length n. In average-case analysis, we consider the average of the running times of all inputs of length n.
Let M be a deterministic TM that halts on all inputs. The time complexity of M if the function f : N −→ N , where f (n) is the maximum number of steps that M uses on any input of length n. If f (n) is the running time of M we say M runs in time f (n) M is an f (n)-time TM.
We seek to understand the running time when the input is “large”. Hence we use an asymptotic notation or big-O notation to characterize the behaviour of f (n) when n is large. The exact value running time function is not terribly important. What is important is how f (n) grows as a function of n, for large n. Differences of a constant factor are not important.
5 n^3 + 2 n^2 + 5 = O(n^3 ) (what are c and n 0 ?) 5 n^3 + 2 n^2 + 5 = O(n^4 ) (what are c and n 0 ?) log 2 (n^8 ) = O(log n) (why?) 5 n^3 + 2 n^2 + 5 is not O(n^2 ) (why?)
2 O(n)^ means an upper bound O( 2 cn) for some constant c. nO(^1 )^ is a polynomial upper bound O(nc^ ) for some constant c.
Assume that your computer/TM can perform 10^9 steps per second. n/f (n) n n log(n) n^2 n^3 2 n 10 0.01 μsec 0.03 μsec 0.1 μsec 1 μsec 1 μsec 20 0.02 μsec 0.09 μsec 0.4 μsec 8 μsec 1 msec 50 0.05 μsec 0.28 μsec 2.5 μsec 125 μsec 13 days 100 0.10 μsec 0.66 μsec 10 μsec 1 msec u 4 × 1013 years 1000 1 μsec 3 μsec 1 msec 1 sec u 3. 4 x 10281 centuries
Clearly, if the running time of your TM is an exponential function of n, it does not matter how fast the TM is!
Let t : N −→ R+^ be a function. TIME(t(n)) = {L(M) | M is a decider running in time O(t(n))}
TIME(t(n)) is the class (collection) of languages that are decidable by TMs, running in time O(t(n)). TIME(n) ⊂ TIME(n^2 ) ⊂ TIME(n^3 ) ⊂... ⊂ TIME( 2 n) ⊂... Examples: { 0 k^1 k^ | k ≥ 0 } ∈ TIME(n^2 ) { 0 k^1 k^ | k ≥ 0 } ∈ TIME(n log n) (next slide) {w#w | w ∈ { 0 , 1 }∗} ∈ TIME(n^2 )
M = “On input w: (^1) Scan the tape and reject if w is not of the form 0∗ 1 ∗^. (^2) Repeat as long as some 0s and some 1s remain on the tape. Scan across the tape, checking whether the total number of 0s and 1s is even or odd. Reject if it is odd. Scan across the tape, crossing off every other 0 starting with the first 0, and every other 1, starting with the first 1. (^3) If no 0’s and no 1’s remain on the tape, accept. Otherwise, reject.
Steps 2 take O(n) time. Step 2 is repeated at most 1 + log 2 n times. (why?) Total time is O(n log n). Hence, { 0 k^1 k^ | k ≥ 0 } ∈ TIME(n log n). However, { 0 k^1 k^ | k ≥ 0 } is decidable on a 2-tape TM in time O(n) (How ?)
A multitape Turing Machine is like an ordinary TM There are k tapes Each tape has its own independent read/write head. The only fundamental difference from the ordinary TM is δ – the state transition function.
δ : Q × Γk^ → Q × Γk^ × {L, R}k
The δ entry δ(qi , a 1 ,... , ak ) = (qj , b 1 ,... , bk , L, R, L, ...L) reads as : If the TM is in state qi and the heads are reading symbols a 1 through ak , Then the machine goes to state qj , and the heads write symbols b 1 through bk , and Move in the specified directions.
We use # as a delimiter to separate out the different tape contents. To keep track of the location of heads, we use additional symbols Each symbol in Γ (except t) has a “dotted” version. A dotted symbol indicates that the head is on that symbol. Between any two #’s there is only one symbol that is dotted. Thus we have 1 real tape with k “virtual’ tapes, and 1 real read/write head with k “virtual” heads.
Given input w = w 1 · · · wn, S puts its tape into the format that represents all k tapes of M
t # · · · #
To simulate a single move of M, S starts at the leftmost # and scans the tape to the rightmost #. It determines the symbols under the “virtual” heads. This is remembered in the finite state control of S. (How many states are needed?) S makes a second pass to update the tapes according to M. If one of the virtual heads, moves right to a #, the rest of tape to the right is shifted to “open up” space for that “virtual tape”. If it moves left to a #, it just moves right again.
Let N be a nondeterministic TM that is a decider. The running time of N is the function f : N −→ N , where f (n) is the maximum number of steps that N uses, on any branch of its computation on any input of length n.
Let t(n) be a function and t(n) ≥ n. Then every t(n) time nondeterministic TM has an equivalent 2O(t(n))^ time deterministic single tape TM.