• Keine Ergebnisse gefunden

Complexity Theory

N/A
N/A
Protected

Academic year: 2022

Aktie "Complexity Theory"

Copied!
13
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Complexity Theory

Martin Ziegler

(2)

Complexity Theory

(3)

Complexity Theory

Reminder: Asymptotics

Landau: For f,g : Í → Ñ write

f=O(g) ⇔ ∃ Mn≥M: f(n)≤M·g(n)

f=Ω(g) ⇔ ∃ Mn≥M: f(n)≥g(n)/M f=Θ

(g)

f=O(g) f=Ω(g)

These notions neglect lower order terms and allow to simplify many expressions e.g. 5·n³-27·n²+933·n+2197 = Θ(n³) further examples in the exercises

f is polynomialy bounded ⇔ ∃ k: f=O(n

k

)

(4)

Complexity Theory

Asymptotic Running Times

Running times of some sorting algorithms

BubbleSort: O(n²) comparisons and copy instr.s QuickSort: typically O(n·log n) steps

but O(n²) in the worst-case

HeapSort: always at most O(n·log n) operations

Here: always worst-case considerations!

w.r.t. input size (e.g. bit length) =: n → ∞

32 years 4 months

19 days

2.5min 100 000

11 days

1 day 1.5 days

2min 10 000

17min 17min

3h

1.5min 1000

40 Mrd. Y 1sec

10sec 11min

1min 100

1msec 1msec

0.1sec 33sec

33sec 10

2n nsec n³ µsec

n² msec n·log n sec

log2n ·10s n

(5)

Complexity Theory

Example Matrix Addition

Example Matrix Multiplication

Input: entries of matrices A,BR

n×n

Wanted: entries of n × n-matrix C := A · B school: n² inner products á O(n):

C2,2 C2,1

C1,2 C1,1

B2,2 B2,1

B1,2 B1,1

A2,2 A2,1

A1,2 A1,1

= ·

Z1:=(A2,1+A2,2)·B1,1 Z2:=(A1,1+A1,2)·B2,2 Z3:=A1,1·(B1,2-B2,2) Z4:=A2,2·(B2,1-B1,1)

Z5:=(A1,1+A2,2)·(B1,1+B2,2) Z6:=(A2,1-A1,1)·(B1,1+B1,2) Z7:=(A1,2-A2,2)·(B2,1+B2,2)

C1,1=Z5+Z4-Z2+Z7 C1,2=Z3+Z2

C2,1=Z1+Z4

C2,2=Z5-Z1+Z3+Z6

Multiplication Multiplication of of nn××nn--matricesmatrices

using using

7 multiplications7 multiplications +18 +18 additionsadditions of (nof (n/2)/2)××((nn/2)/2)--matrizesmatrizes

O O ( ( n n ³ ³ ) )

L(n) = 7· L(

n/2

) + 18·(n/2)²

L L ( ( n n ) = ) = O O ( ( n n

loglog2277

), ), log log

22

7 7 ≈ ≈ 2,81 2,81

Fix a ring (R, + , − ,0, × ,1)

World

World recordrecord: O(: O(nn2.382.38) )

[Coppersmith&Winograd'90]

[Coppersmith&Winograd'90]

MoreMore on Jan.11, 2012on Jan.11, 2012 in in ourour colloqiumcolloqium……

asymptotics dominated by

#multiplications

O O ( ( n n ² ² ), ),

optimal optimal

+

(6)

Complexity Theory

Models of Computation

Matrix Multipl. count arithmetic operations

2n² inputs, n² outputs: Ω(n²).

HeapSort: O(n·log n) operations

Can improve (asymptotically) ?

Yes, 1 operation suffices: sort(x1,…,xn)

Complexity subj.to model of computation:

mathem. formalization (&idealization)

which operationen are available

and at what 'cost' in terms of resources

resources such as (run) time, memory,

#prozessors (parallel computing)

Here mostly Turing Maschines

(7)

Complexity Theory

Alan M. Turing [1937]

mathematical

idealization and abstraction of his

assistents (so called

„computers“)

nowadays generally accepted als model

for digital computing machines (PCs)

Turing Maschine

(8)

Complexity Theory

determ. 1-tape TM

4-tupel M = (Q, Σ, Γ, δ):

Q finite set of states

with s=initial state

q+=accept. final state, q-=reject. final state

Σ finite input alphabet

with , B ∉ Σ (blank, boundary symbol)

Γ finite tape alphabet

where Σ ⊂ Γ and , B ∈ Γ.

δ : Q\{q

+

,q

-

} × Γ → Q × Γ × {R,L,N}

denotes the transition function

(9)

Complexity Theory

Configuration, Successor, Computation

M = (Q,Σ,Γ,δ); Γ* = { finite sequen.s over Γ } Configuration: α q β, here „110 q5 01110“

(beyond β only s; β does not end on )

one step according to δ: direct

successor configuration α q β

¢

α' p β'

n-th successor configuration K

¢

n K''

(indirect) successor configuration K

¢

* K''

M accepts w if there

are α‘,β‘∈Γ* with s w

¢

* α‘ q+ β‘

M rejects w if s w

¢

* α‘ q- β‘

(10)

Complexity Theory

Acceptance und Decision

The language accepted by M is L( M ) := { w : M accepts w }

For wL(M), M may enter a closed loop!

M decides L( M ) if it in addition rejects every w ∈ Σ*\L.

L ⊆ Σ* called semi-decidable if accepted by some TM;

L called decidable

if decided by some TM.

M accepts w if there exists α‘,β‘∈Γ* with s w ¢* α‘ q+ β‘

M rejects w if there exists α‘,β‘∈Γ* with s w ¢* α‘ q- β‘

(11)

Complexity Theory

Some logical considerations

TM

M=(Q,Σ,Γ,δ) with Q,Σ,Γ finite sets

and δ : Q\{q

+

,q

-

} × Γ → Q × Γ × {R,L,N}

Renaming states does not really affect the TM There are only

countably many TMs

but

continuously many L

Σ* (Cantor)

Each TM semi-decides precisely one

L

Σ*.

Almost every L⊆Σ* is not semi-decidable!

Gödel: truth of arithmetic sentences not (semi-)

decidable; Davis, Robinson, Matiyasevich: Unsolvability of diophantic equations not semi-decidable

L ⊆ Σ* called semi-decidable if there exists

a TM accepting precisely those w in L.

(12)

Complexity Theory

Resource: Time

Let M=(Q,Σ,Γ,δ) denote a DTM.

One step is a direct transition between configurations α q β

¢

α‘ p β‘

For w∈Σ* let TM(w) denote the number of steps M executes on input w before terminating;

TM(w):=∞ if M does not terminate on w.

For n∈N let TM(n):=max{TM(w) | w∈Σ≤n}

denote the (worst-case) running time of M on inputs of length ≤n;

TM:N→N is the running time function of M

TM(n)

O(

t(n)

)

: M called

O(

t(n)

)

-time bounded

DTIME(

t(n)

)

:= { L(M) :

DTM M is

O(

t(n)

)

―time bounded}

(13)

Complexity Theory

Example TM for Palindromes

Q := { s , q

r0

, q

r1

, q

z0

, q

z1

, q

, q

+

, q

-

} δ informally:

s: first symbol is ? Then q+

Otherwise 'remember' first symbol i in state qri overwrite with , and skip one cell to the right qri: scan tape to the right for

then skip back by one cell and enter state qzi qzi: present symbol different from i? →state q-

(over)write , state q and one cell to the left

q: scan left for then right, restart with state s

PALIN := { w ∈ {0,1}*: w=w

®

}

Referenzen

ÄHNLICHE DOKUMENTE

Nutzungseinheit über mehrere Geschoße verteilt Eingabe der Bruttoflächen auf Ebene der Geschoße Flächen auf Gebäudeebene: bebaute

Euro Bei Dauerversorgung, zentrale Bearbeitung

Theorem 6.11 Das Voronoi Diagramm von n Punkten l¨ aßt sich mit dem Sweep Algorithmus in Zeit O(n log n) und mit Platz O (n). berechnen, das

mit Kaplan Michael Sippel, Beauftragter für Kirche und Sport Im Anschluss kleiner Imbiss stadionlike mit Trainingseinheit, danach Vortrag von Pfarrer Eugen Eckert.. Eugen Eckert

[r]

Unsere Betten sind ideal für alle, insbesondere jedoch für große Menschen mit bis zu 210 cm Länge....

T oten sondern lassen. D en n in diese beiden Gruppen strömen au^ der Arbeiterschaft die beweglichen E lem ente ab.. Auch dieser ist ein Rückgriff auf U rftadien

Spielerinnen und Spieler, deren Mannschaft in derselben Liga spielen, sind nur für eine Mannschaft innerhalb eines Spiels gegeneinander