Professional Documents
Culture Documents
Complexity of Problems
Classifying Problems
The Aim
All
Languages
Decidable
Languages
Question
¹see http://www.faber.co.uk/faber/million_dollar.asp
Computability and Complexity 11-5
Complexity Measures
Every decidable problem has a set of algorithms ( TMs) that solve it.
²This has proved useful for classifying the complexity of strings, where
it is called Kolmogorov complexity. See “Introduction to Kolmogorov Complexity
and its Applications”, Li and Vitani, 1993
Computability and Complexity 11-6
Blum’s Axioms
Blum proposed³ that any useful dynamic complexity measure should
satisfy the following properties:
Time Complexity
The most critical computational resource is often time, so the most
useful complexity measure is often time complexity
Definition
Definition The
The time
timecomplexity
complexity ofofaaTuring
TuringMachine
Machine TT isisthe
the
function
function Time T suchsuchthat
that Time T ( x ) isisthe
thenumber
numberofof
steps
stepstaken
takenby
bythe
thecomputation
computation T(x)
T(x)
Space Complexity
Another important computational resource is amount of “memory”
used by an algorithm, that is space. The corresponding complexity
measure is space complexity
Definition
Definition The
The space
spacecomplexity
complexity ofofaaTuring
TuringMachine
Machine TT isisthe
the
function
function Space T such suchthat
that Space T ( x ) isisthe
thenumber
numberofof
distinct
distincttape
tapecells
cellsvisited
visitedduring
duringthe
thecomputation
computation T(x)
T(x)
Theorem
Theorem For Forany
anyTuring
TuringMachine
Machine TT that
thatdecides
decidesaalanguage
language L, L,
and anymm,
andany , there
thereisisanother
anotherTuring
TuringMachine
Machine T’T’ that
thatalso
also
decides L, such
decides L, suchthat
that
Time T ( x)
Time T ' ( x) 2| x|
m
Proof
The machine T' has a larger alphabet than T, many more states, and
an extra tape.
T' first compresses its input by writing a symbol on a new tape encoding
each k-tuple of symbols of the original input. It then returns the head to
the leftmost cell. This takes 2|x| steps in total
Table Look-Up
Theorem
Theorem For Forany
anyTuring
TuringMachine
Machine TT that
thatdecides
decidesaalanguage
language L, L,
and anymm,
andany , there
thereisisanother
anotherTuring
TuringMachine
Machine T'T' that
thatalso
also
decides L, such
decides L, suchthat
thatfor
forall
allinputs
inputs xx with
with |x|m,
|x|m,
Time T ' ( x ) | x |
Computability and Complexity 11-15
Proof Idea
The machine T' has additional states corresponding to each possible input
of length at most m
T' first reads to the end of the input, remembering what it has seen by
going into the corresponding state. If it reaches the end of the input in
one of its special states it then immediately halts, giving the desired
answer.
Given any decidable language, and any TM that decides it, we have
seen that we can construct a TM that
Math Prerequisites
Examples
• A polynomial of degree k is O ( n k )
5n 3 7n 2 3n 110 O ( n 3 )
• log(n k ) O (log n )
• log a n O (log b n )
Computability and Complexity 11-18
Math Prerequisites
In other words, f(n)=o(g(n)) means that, for any real number c, there
is n0 such that for every n n0
f ( n ) cg ( n )
Examples
• n k 1 o( n k ) n o( n 2 ), n 2 o( n 3 ),...
• log k 1 n o(log k n )
• log n o( n )
k m
• n o( a ), a 1
k n
Computability and Complexity 11-19
Definition
Definition
For
Forany
anyfunction
function f,f, we
wesay
saythat
thatthe
thetime
timecomplexity
complexityofofaa
decidable
decidablelanguage
language LL isisinin O(f)
O(f) ififthere
thereexists
existsaaTuring
Turing
Machine
Machine TT which
whichdecides
decides L, L, and
andconstants
constants n0 andand cc
such
suchthat
thatfor
forall
allinputs with | x | n0
inputs xx with
Time T ( x ) cf (| x |)
Computability and Complexity 11-20
Complexity Classes
Definition
Definition
The
The timetimecomplexity
complexityclass TIME[f] isisdefined
class TIME[f] definedtotobe
bethe
theclass
class
ofofall
alllanguages
languageswith
withtime
timecomplexity
complexityinin O(f)
O(f)
Examples
All
Languages
Decidable
Languages
O (n ) O (n 2 ) O (2 n )
O ( n log n )