• Keine Ergebnisse gefunden

Algorithmen und Komplexität

N/A
N/A
Protected

Academic year: 2022

Aktie "Algorithmen und Komplexität"

Copied!
768
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Algorithmen und Komplexität

Stephan Schulz

stephan.schulz@dhbw-stuttgart.de Jan Hladik

jan.hladik@dhbw-stuttgart.de

(2)

Inhaltsverzeichnis I

1 Einf ¨uhrung 2 Komplexit ¨at

O-Notation

Einschub: Logarithmen Komplexit ¨at anschaulich Dynamisches

Programmieren Rekurrenzen und Divide&Conquer 3 Arrays

4 Listen 5 Sortieren

Einfache Sortierverfahren Sortieren mit Divide-and-Conquer Heaps and Heapsort Sortieren – Abschluss 6 Schl ¨usselmengen/Wert-

Verwaltung

Bin ¨are Suchb ¨aume Balancierte B ¨aume und AVL-B ¨aume

Hashing 7 Graph-Algorithmen

Minimale Spannb ¨aume

& Algorithmus von Prim K ¨urzeste Wege/Dijkstra 8 Zusammenfassung 9 Einzelvorlesungen

Vorlesung 1 Vorlesung 2 Vorlesung 3 Vorlesung 4 Vorlesung 5 Vorlesung 6 Vorlesung 7 Vorlesung 8 Vorlesung 9 Vorlesung 10

Vorlesung 11 Vorlesung 12 Vorlesung 13 Vorlesung 14 Vorlesung 15 Vorlesung 16 Vorlesung 17 Vorlesung 18 Vorlesung 19 Vorlesung 20 Vorlesung 21 Vorlesung 22

10 L ¨osungen Einfache O-Bestimmung O-Bestimmung Master-Theorem Analyse von Selection-Sort

Einf ¨ugen in AVL-B ¨aume

2

(3)

Semester ¨ubersicht

I Was sind Algorithmen?

I Wie kann man die Komplexit ¨at von Algorithmen beschreiben?

I Platzbedarf

I Zeitbedarf

I Mathematische Werkzeuge zur Komplexit ¨atsanalyse

I Z.B. Rekurrenzrelationen

I Klassifikation von Algorithmen

I Z.B. Brute Force, Greedy, Divide&Conquer, Dynamic Programming

I Ans ¨atze zur Algorithmenentwicklung

I Algorithmen und Datenstrukturen

I Arrays

I Listen

I Suchb ¨aume

I Heaps

I Hashes

I Graphen

3

(4)

Sonstiges zum Kurs

I Begleitendes LaborAngewandte Informatik

I Algorithmentwicklung in C

I Webseiten zum Kurs:

http://wwwlehre.dhbw-stuttgart.de/˜sschulz/algo2018.html

I Folienskript zur Vorlesung

I Aufgaben zum Labor

I Musterl ¨osungen

4

(5)

Literatur

I Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein:Introduction to Algorithms

I 3. Auflage 2009, moderner Klassiker (der Titel l ¨ugt)

I Robert Sedgewick, Kevin Wayne:Algorithms

I 4. Auflage 2011, moderner Klassiker

I Ahnlich auch als¨ Algorithms in C/Java/C++

I Donald Knuth:The Art of Computer Programming

I Die Bibel, seit 1962, Band 1 1968 (3. Auflage 1997), Band 4a 2011, Band 5 geplant f ¨ur 2020 (!)

I Niklaus Wirth:Algorithmen und Datenstrukturen

I Deutschsprachiger Klassiker (1. Auflage 1975), 5. Auflage 2013

5

(6)

Literatur

I Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein:Introduction to Algorithms

I 3. Auflage 2009, moderner Klassiker (der Titel l ¨ugt)

I Robert Sedgewick, Kevin Wayne:Algorithms

I 4. Auflage 2011, moderner Klassiker

I Ahnlich auch als¨ Algorithms in C/Java/C++

I Donald Knuth:The Art of Computer Programming

I Die Bibel, seit 1962, Band 1 1968 (3. Auflage 1997), Band 4a 2011, Band 5 geplant f ¨ur 2020 (!)

I Niklaus Wirth:Algorithmen und Datenstrukturen

I Deutschsprachiger Klassiker (1. Auflage 1975), 5. Auflage 2013

5

(7)

Literatur

I Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein:Introduction to Algorithms

I 3. Auflage 2009, moderner Klassiker (der Titel l ¨ugt)

I Robert Sedgewick, Kevin Wayne:Algorithms

I 4. Auflage 2011, moderner Klassiker

I Ahnlich auch als¨ Algorithms in C/Java/C++

I Donald Knuth:The Art of Computer Programming

I Die Bibel, seit 1962, Band 1 1968 (3. Auflage 1997), Band 4a 2011, Band 5 geplant f ¨ur 2020 (!)

I Niklaus Wirth:Algorithmen und Datenstrukturen

I Deutschsprachiger Klassiker (1. Auflage 1975), 5. Auflage 2013

5

(8)

Literatur

I Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein:Introduction to Algorithms

I 3. Auflage 2009, moderner Klassiker (der Titel l ¨ugt)

I Robert Sedgewick, Kevin Wayne:Algorithms

I 4. Auflage 2011, moderner Klassiker

I Ahnlich auch als¨ Algorithms in C/Java/C++

I Donald Knuth:The Art of Computer Programming

I Die Bibel, seit 1962, Band 1 1968 (3. Auflage 1997), Band 4a 2011, Band 5 geplant f ¨ur 2020 (!)

I Niklaus Wirth:Algorithmen und Datenstrukturen

I Deutschsprachiger Klassiker (1. Auflage 1975), 5. Auflage 2013

5

(9)

Informelle Definition: Algorithmus

I Ein Algorithmus ist ein Verfahren zur L ¨osung eines Problems oder einer Problemklasse

I Ein Algorithmus. . .

I . . . ¨uberf ¨uhrt eine Eingabe in eine Ausgabe

I . . . besteht aus endlich vielen Einzelschritten

I . . . ist ohne tiefes Verst ¨andnis durchf ¨uhrbar

I Jeder Einzelschritt ist wohldefiniert, ausf ¨uhrbar, und terminiert nach endlicher Zeit

I Gelegentliche Forderung: Der Algorithmus terminiert (problematisch)

I Formalisierung: z.B. Turing-Maschine

Alan Turing (1912–1954)

6

(10)

Der Begriff Algorithmus

Muhammad ibn Musa al-Khwarizmi

I Mathematiker, Astronom, Geograph

I geboren ca. 780 nahe des Aralsees (heute Usbekistan)

I gestorben ca. 850 in Bagdad

I Latinisiert alsAlgaurizin,Algorismi,Algoritmi

I zahlreiche Werke

I Algoritmi de numero Indorum

I Rechenverfahren

I Algebra

7

(11)

Der Begriff Algorithmus

Muhammad ibn Musa al-Khwarizmi

I Mathematiker, Astronom, Geograph

I geboren ca. 780 nahe des Aralsees (heute Usbekistan)

I gestorben ca. 850 in Bagdad

I Latinisiert alsAlgaurizin,Algorismi,Algoritmi

I zahlreiche Werke

I Algoritmi de numero Indorum

I Rechenverfahren

I Algebra

7

(12)

Der Begriff Algorithmus

Muhammad ibn Musa al-Khwarizmi

I Mathematiker, Astronom, Geograph

I geboren ca. 780 nahe des Aralsees (heute Usbekistan)

I gestorben ca. 850 in Bagdad

I Latinisiert alsAlgaurizin,Algorismi,Algoritmi

I zahlreiche Werke

I Algoritmi de numero Indorum

I Rechenverfahren

I Algebra

7

(13)

Einige Klassen von Algorithmen

I Suchalgorithmen

I Schl ¨ussel in Datenbank

I Pfad in Umgebung/Landkarte/Graph

I Beweis in Ableitungsraum

I Sortierverfahren

I Total

I Topologisch

I Optimierungsverfahren

I Spielpl ¨ane

I Kostenminimierung

I Komprimierung

I Lossy

I Lossless

I Mathematische Algorithmen

I Faktorisierung

I Gr ¨oßter gemeinsamer Teiler

I Gauß-Verfahren

I . . .

8

(14)

Beispiel: Euklids GGT-Algorithmus

I Problem: Finde den gr ¨oßten gemeinsamen Teiler (GGT) (greatest common divisor, GCD) f ¨ur zwei nat ¨urliche Zahlenaundb.

I Also: Eingabea,b∈N

I Ausgabe:c ∈Nmit folgenden Eigenschaften:

I cteiltaohne Rest

I cteiltbohne Rest

I cist die gr ¨oßte nat ¨urliche Zahl mit diesen Eigenschaften

I Beispiele:

I ggt(12,9) =3

I ggt(30,15) =15

I ggt(25,11) =1

9

(15)

Beispiel: Euklids GGT-Algorithmus

Euklid von Alexandria (ca. 3 Jh. v. Chr.), Elemente

I Berechnung des GGT in Euklids Worten:

Wenn CD aber AB nicht misst, und man nimmt bei AB, CD abwechselnd immer das kleinere vom gr ¨oßeren weg, dann muss (schließlich) eine Zahl

¨ubrig bleiben, die die vorangehende misst.

Elemente, Buch VII, Behauptung 2

10

(16)

Beispiel: Euklids GGT-Algorithmus

Euklid von Alexandria (ca. 3 Jh. v. Chr.), Elemente

I Berechnung des GGT in Euklids Worten:

Wenn CD aber AB nicht misst, und man nimmt bei AB, CD abwechselnd immer das kleinere vom gr ¨oßeren weg, dann muss (schließlich) eine Zahl

¨ubrig bleiben, die die vorangehende misst.

Elemente, Buch VII, Behauptung 2

10

(17)

Beispiel: Euklids GGT-Algorithmus

Euklids Algorithmus moderner:

I Gegeben: Zwei nat ¨urliche Zahlenaundb

I Wenna=b: Ende, der GGT ista

I Ansonsten:

I Seic die absolute Differenz vonaundb.

I Bestimme den GGT vonc und dem kleineren der beiden Werteaundb

DerPharos von Alexandria, Bild: Emad Victor Shenouda

11

(18)

Ubung: Euklids GGT-Algorithmus ¨

I Algorithmus

I Gegeben: Zwei nat ¨urliche Zahlenaundb

I Wenna=b: Ende, der GGT ista

I Ansonsten: Seic die absolute Differenz vonaundb.

I Bestimme den GGT voncund dem kleineren der beiden Wertea undb

I Aufgabe: Bestimmen Sie mit Euklids Algorithmus die folgenden GGTs. Notieren Sie die Zwischenergebnisse.

I ggt(16,2)

I ggt(36,45)

I ggt(17,2)

I ggt(121,55)

I ggt(2,0)

12

(19)

Spezifikation von Algorithmen

Algorithmen k ¨onnen auf verschiedene Arten beschrieben werden:

I Informeller Text

I Semi-Formaler Text

I Pseudo-Code

I Konkretes Programm in einer Programmiersprache

I Flussdiagramm

I . . .

13

(20)

Euklid als (semi-formaler) Text

I Algorithmus: Gr ¨oßter gemeinsamer Teiler

I Eingabe: Zwei nat ¨urliche Zahlena,b

I Ausgabe: Gr ¨oßter gemeinsamer Teiler vonaundb

1 Wennagleich 0, dann ist das Ergebnisb. Ende.

2 Wennbgleich 0, dann ist das Ergebnisa. Ende.

3 Wennagr ¨oßer alsbist, dann setzeagleichab.

Mache mit Schritt 3 weiter.

4 Wennbgr ¨oßer alsaist, dann setzebgleichba.

Mache mit Schritt 3 weiter.

5 Ansonsten:aist gleichb, und ist der gesuchte GGT. Ende.

14

(21)

Euklid als (Pseudo-)Code

def e u c l i d g c d ( a , b ) :

” ” ”

Compute t h e G r e a t e s t Common D i v i s o r o f two numbers , u s i n g E u c l i d ’ s n a i v e a l g o r i t h m .

” ” ” i f a ==0:

r e t u r n b i f b ==0:

r e t u r n a while a ! = b : i f a>b :

a=ab else:

b=ba r e t u r n a

15

(22)

Euklid Rekursiv

def e u c l i d g c d r ( a , b ) :

” ” ”

Compute t h e G r e a t e s t Common D i v i s o r o f two numbers , u s i n g E u c l i d ’ s n a i v e a l g o r i t h m .

” ” ” i f a ==0:

r e t u r n b i f b ==0:

r e t u r n a i f a>b :

r e t u r n e u c l i d g c d r ( ab , b ) else:

r e t u r n e u c l i d g c d r ( b , ba )

16

(23)

Panta Rhei

I Flussdiagramm: Graphische Visualisierung des Algorithmus

I Wer findet den Fehler? Was passiert bei A=0,B 6=0?

17

(24)

Panta Rhei

I Flussdiagramm: Graphische Visualisierung des Algorithmus

I Wer findet den Fehler?

Was passiert bei A=0,B 6=0?

17

(25)

Panta Rhei

I Flussdiagramm: Graphische Visualisierung des Algorithmus

I Wer findet den Fehler?

Was passiert bei A=0,B6=0?

17

(26)

Ubung: Euklids Worst Case ¨

I Wie oft durchl ¨auft der Euklidsche Algorithmus im schlimmsten Fall f ¨ur ein gegebenesa+bdie Schleife? Begr ¨unden Sie Ihr Ergebnis!

18

(27)

Das Geheimnis des Modulus

I Dermodulo-Operator ermittelt den Divisionsrestbei der ganzzahligen Division:

I Sei z.B.z=nq+r

I Dann ist

z/n=qmit Restr

I oder auch:

z/n=qundz%n=r

I Alternative Schreibweise:

zdivn=qundzmodn=r

Dividend

Divisor (Zähler)

(Nenner) Modulus

(Rest)

z.B. 15

z.B. 4 z.B. 3

Quotient z.B. 3

19

(28)

Modulus Teil 2

I Eigenschaften:

I Der Divisionsrestmodulonliegt zwischen 0 undn1

I Aufeinanderfolgende Zahlen

kleinernhaben aufeinanderfolgende Divisionsreste

I Aufeinanderfolgende Zahlen haben meistensaufeinanderfolgende Divisionsreste (Ausnahme: Die gr ¨oßere ist glatt durchnteilbar)

I Verwendung:

I Kryptographie (RSA)

I Hashing

I “Faire” Verteilung aufnT ¨opfe

Dividend

Divisor (Zähler)

(Nenner) Modulus

(Rest)

z.B. 15

z.B. 4 z.B. 3

Quotient z.B. 3

20

(29)

Modulus Teil 3

Beispiele

Divident Divisor Quotient Modulus

0 3 0 0

1 3 0 1

2 3 0 2

3 3 1 0

4 3 1 1

5 3 1 2

6 3 2 0

25 17 1 8

26 17 1 9

27 17 1 10

34 17 2 0

35 17 2 1

Dividend

Divisor (Zähler)

(Nenner) Modulus

(Rest)

z.B. 15

z.B. 4 z.B. 3

Quotient z.B. 3

21

(30)

Modulus Teil 3

Beispiele

Divident Divisor Quotient Modulus

0 3 0 0

1 3 0 1

2 3 0 2

3 3 1 0

4 3 1 1

5 3 1 2

6 3 2 0

25 17 1 8

26 17 1 9

27 17 1 10

34 17 2 0

35 17 2 1

37 1

Dividend

Divisor (Zähler)

(Nenner) Modulus

(Rest)

z.B. 15

z.B. 4 z.B. 3

Quotient z.B. 3

21

(31)

Modulus Teil 3

Beispiele

Divident Divisor Quotient Modulus

0 3 0 0

1 3 0 1

2 3 0 2

3 3 1 0

4 3 1 1

5 3 1 2

6 3 2 0

25 17 1 8

26 17 1 9

27 17 1 10

34 17 2 0

35 17 2 1

37 1 37 0

Dividend

Divisor (Zähler)

(Nenner) Modulus

(Rest)

z.B. 15

z.B. 4 z.B. 3

Quotient z.B. 3

21

(32)

Ubung: Modulus ¨

11 mod 15 = 19 mod 23 = 52 mod 2 = 82 mod 12 = 54 mod 29 = 66 mod 10 = 44 mod 26 = 12 mod 16 = 23 mod 15 = 96 mod 20 = 26 mod 15 = 87 mod 17 = 93 mod 26 = 64 mod 14 = 68 mod 20 = 99 mod 14 = 15 mod 25 = 36 mod 23 = 34 mod 19 = 28 mod 27 = 46 mod 14 = 71 mod 24 = 84 mod 24 = 62 mod 20 = 76 mod 27 = 21 mod 20 = 38 mod 17 = 96 mod 23 = 36 mod 14 = 44 mod 13 = 35 mod 25 = 72 mod 29 = 32 mod 7 =

22

(33)

Ubung: Modulus ¨

11 mod 15 =

11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(34)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 =

19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(35)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 =

0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(36)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 =

10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(37)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 =

25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(38)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 =

6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(39)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 =

18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(40)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 =

12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(41)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 =

8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(42)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 =

16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(43)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 =

11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(44)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 =

2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(45)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 =

15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(46)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 =

8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(47)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 =

8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(48)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 =

1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(49)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 =

15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(50)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 =

13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(51)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 =

15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(52)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 =

1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(53)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 =

4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(54)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 =

23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(55)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 =

12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(56)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 =

2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(57)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 =

22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(58)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 =

1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(59)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 =

4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(60)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 =

4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(61)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 =

8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(62)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 =

5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(63)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 =

10 72 mod 29 = 14 32 mod 7 = 4 Geschafft!

Ende Vorlesung 1

23

(64)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 =

14 32 mod 7 = 4 Geschafft!

Ende Vorlesung 1

23

(65)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 =

4 Geschafft!

Ende Vorlesung 1

23

(66)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(67)

Ubung: Modulus ¨

11 mod 15 = 11 19 mod 23 = 19 52 mod 2 = 0 82 mod 12 = 10 54 mod 29 = 25 66 mod 10 = 6 44 mod 26 = 18 12 mod 16 = 12 23 mod 15 = 8 96 mod 20 = 16 26 mod 15 = 11 87 mod 17 = 2 93 mod 26 = 15 64 mod 14 = 8 68 mod 20 = 8 99 mod 14 = 1 15 mod 25 = 15 36 mod 23 = 13 34 mod 19 = 15 28 mod 27 = 1 46 mod 14 = 4 71 mod 24 = 23 84 mod 24 = 12 62 mod 20 = 2 76 mod 27 = 22 21 mod 20 = 1 38 mod 17 = 4 96 mod 23 = 4 36 mod 14 = 8 44 mod 13 = 5 35 mod 25 = 10 72 mod 29 = 14 32 mod 7 = 4

Geschafft!

Ende Vorlesung 1

23

(68)

GGT-Algorithmus von Euklid

I Algorithmus: Gr ¨oßter gemeinsamer Teiler

I Eingabe: Zwei nat ¨urliche Zahlena,b

I Ausgabe: Gr ¨oßter gemeinsamer Teiler vonaundb

1 Wennagleich 0, dann ist das Ergebnisb. Ende.

2 Wennbgleich 0, dann ist das Ergebnisa. Ende.

3 Wennagr ¨oßer alsbist, dann setzeagleichab.

Mache mit Schritt 3 weiter.

4 Wennbgr ¨oßer alsaist, dann setzebgleichba.

Mache mit Schritt 3 weiter.

5 Ansonsten:aist gleichb, und ist der gesuchte GGT. Ende.

24

(69)

Analyse: Euklids GGT-Algorithmus

Seio.B.d.A agr ¨oßer alsbund seigder ggt(a,b)

I Dann gilt:a=m·g undb=n·g f ¨urm,n∈Nundm>n

I Nach einem Schritt ist alsoa= (m−n)gundb=n·g

I gteilt immer nochaundb(Korrektheit!)

I Wennmgroß gegennist, dann durchl ¨auft der Algorithmus viele Schritte, bisabgilt

Geht das auch schneller?

25

(70)

Analyse: Euklids GGT-Algorithmus

Seio.B.d.A agr ¨oßer alsbund seigder ggt(a,b)

I Dann gilt:a=m·g undb=n·g f ¨urm,n∈Nundm>n

I Nach einem Schritt ist alsoa= (m−n)gundb=n·g

I gteilt immer nochaundb(Korrektheit!)

I Wennmgroß gegennist, dann durchl ¨auft der Algorithmus viele Schritte, bisabgilt

Geht das auch schneller?

25

(71)

Euklid Schneller

Seio.B.d.A agr ¨oßer alsbund seigder ggt(a,b)

I Dann gilt:a=m·g undb=n·g f ¨urm,n∈Nundm>n

I Nach einem Schritt ist alsoa= (m−n)gundb=n·g

I gteilt immer nochaundb(Korrektheit!)

I Wennmgroß gegennist, dann durchl ¨auft der Algorithmus viele Schritte, bisabgilt

I Beobachtung: Es wird so lange immer wiederbvonaabgezogen, bisa≤bgilt!

I Sei im folgendena0 der Originalwert vona

I Wenn wirb i-mal vona0abziehen, so gilt also:a0 =ib+a

I In anderen Worten:aist der Divisionsrest vona0/b!

Wir k ¨onnen also die wiederholten Subtraktionen durch eine Division mit Restberechnung ersetzen!

26

(72)

Euklid Schneller

Seio.B.d.A agr ¨oßer alsbund seigder ggt(a,b)

I Dann gilt:a=m·g undb=n·g f ¨urm,n∈Nundm>n

I Nach einem Schritt ist alsoa= (m−n)gundb=n·g

I gteilt immer nochaundb(Korrektheit!)

I Wennmgroß gegennist, dann durchl ¨auft der Algorithmus viele Schritte, bisabgilt

I Beobachtung: Es wird so lange immer wiederbvonaabgezogen, bisa≤bgilt!

I Sei im folgendena0 der Originalwert vona

I Wenn wirb i-mal vona0abziehen, so gilt also:a0 =ib+a

I In anderen Worten:aist der Divisionsrest vona0/b!

Wir k ¨onnen also die wiederholten Subtraktionen durch eine Division mit Restberechnung ersetzen!

26

(73)

Euklid Schneller in (Pseudo)-Code

def e u c l i d g c d 2 ( a , b ) :

” ” ” Compute t h e G r e a t e s t Common D i v i s o r o f two numbers , u s i n g an improved v e r s i o n od E u c l i d ’ s a l g o r i t h m .

” ” ”

while a ! = b : i f a ==0:

r e t u r n b i f b ==0:

r e t u r n a i f a>b :

a=a%b else:

b=b%a r e t u r n a

27

(74)

Ubung: Euklid Schneller ¨

I Aufgabe: Bestimmen Sie mit dem verbesserten Algorithmus die folgenden GGTs. Notieren Sie die Zwischenergebnisse.

I ggt(16,2)

I ggt(36,45)

I ggt(17,2)

I ggt(121,55)

I ggt(89,55)

def e u c l i d g c d 2 ( a , b ) : while a ! = b :

i f a ==0:

r e t u r n b i f b ==0:

r e t u r n a i f a>b :

a=a%b else:

b=b%a r e t u r n a

28

(75)

Gruppen ¨ubung: Analyse von Euklid

I Wie viele Schritte/Schleifendurchl ¨aufe braucht der Euklidsche Algorithmus ungef ¨ahr?

I Fall 1: Naiver Euklid (mit Subtraktiona−b):

I Schlimmster Fall:b=1, dannaSchritte

I Fall 2: Verbesserter Algorithmus mitModulus amodb

I Ans ¨atze: Betrachte z.B.max(a,b)odera+bvor und nach einem Schritt

I Wie entwickelt sich dieser Wert?

I Ista2b:amodb<ba/2

I Ista<2b:amodsb=abaa/2a/2

I Also:aschrumpft auf h ¨ochstens die H ¨alfte

I Außerdem: Nach dem Schritt istbgr ¨oßergleich dem neuena

I Also: Im n ¨achsten Schritt schrumpftbauf h ¨ochstens die H ¨alfte

I Zusammen: Nach zwei Schritten ista+bum mindestens den Faktor 2 geschrumpft!

I Wie oft kann eine Ganzzahl sich halbieren, bis 1 herauskommt? Anzahl der Schleifendurchl ¨aufe ist beschr ¨ankt durch 2 log2(a+b)

29

(76)

Gruppen ¨ubung: Analyse von Euklid

I Wie viele Schritte/Schleifendurchl ¨aufe braucht der Euklidsche Algorithmus ungef ¨ahr?

I Fall 1: Naiver Euklid (mit Subtraktiona−b):

I Schlimmster Fall:b=1, dannaSchritte

I Fall 2: Verbesserter Algorithmus mitModulus amodb

I Ans ¨atze: Betrachte z.B.max(a,b)odera+bvor und nach einem Schritt

I Wie entwickelt sich dieser Wert?

I Ista2b:amodb<ba/2

I Ista<2b:amodsb=abaa/2a/2

I Also:aschrumpft auf h ¨ochstens die H ¨alfte

I Außerdem: Nach dem Schritt istbgr ¨oßergleich dem neuena

I Also: Im n ¨achsten Schritt schrumpftbauf h ¨ochstens die H ¨alfte

I Zusammen: Nach zwei Schritten ista+bum mindestens den Faktor 2 geschrumpft!

I Wie oft kann eine Ganzzahl sich halbieren, bis 1 herauskommt? Anzahl der Schleifendurchl ¨aufe ist beschr ¨ankt durch 2 log2(a+b)

29

(77)

Gruppen ¨ubung: Analyse von Euklid

I Wie viele Schritte/Schleifendurchl ¨aufe braucht der Euklidsche Algorithmus ungef ¨ahr?

I Fall 1: Naiver Euklid (mit Subtraktiona−b):

I Schlimmster Fall:b=1, dannaSchritte

I Fall 2: Verbesserter Algorithmus mitModulus amodb

I Ans ¨atze: Betrachte z.B.max(a,b)odera+bvor und nach einem Schritt

I Wie entwickelt sich dieser Wert?

I Ista2b:amodb<ba/2

I Ista<2b:amodsb=abaa/2a/2

I Also:aschrumpft auf h ¨ochstens die H ¨alfte

I Außerdem: Nach dem Schritt istbgr ¨oßergleich dem neuena

I Also: Im n ¨achsten Schritt schrumpftbauf h ¨ochstens die H ¨alfte

I Zusammen: Nach zwei Schritten ista+bum mindestens den Faktor 2 geschrumpft!

I Wie oft kann eine Ganzzahl sich halbieren, bis 1 herauskommt? Anzahl der Schleifendurchl ¨aufe ist beschr ¨ankt durch 2 log2(a+b)

29

(78)

Gruppen ¨ubung: Analyse von Euklid

I Wie viele Schritte/Schleifendurchl ¨aufe braucht der Euklidsche Algorithmus ungef ¨ahr?

I Fall 1: Naiver Euklid (mit Subtraktiona−b):

I Schlimmster Fall:b=1, dannaSchritte

I Fall 2: Verbesserter Algorithmus mitModulus amodb

I Ans ¨atze: Betrachte z.B.max(a,b)odera+bvor und nach einem Schritt

I Wie entwickelt sich dieser Wert?

I Ista2b:amodb<ba/2

I Ista<2b:amodsb=abaa/2a/2

I Also:aschrumpft auf h ¨ochstens die H ¨alfte

I Außerdem: Nach dem Schritt istbgr ¨oßergleich dem neuena

I Also: Im n ¨achsten Schritt schrumpftbauf h ¨ochstens die H ¨alfte

I Zusammen: Nach zwei Schritten ista+bum mindestens den Faktor 2 geschrumpft!

I Wie oft kann eine Ganzzahl sich halbieren, bis 1 herauskommt?

Anzahl der Schleifendurchl ¨aufe ist beschr ¨ankt durch 2 log2(a+b)

29

(79)

Gruppen ¨ubung: Analyse von Euklid

I Wie viele Schritte/Schleifendurchl ¨aufe braucht der Euklidsche Algorithmus ungef ¨ahr?

I Fall 1: Naiver Euklid (mit Subtraktiona−b):

I Schlimmster Fall:b=1, dannaSchritte

I Fall 2: Verbesserter Algorithmus mitModulus amodb

I Ans ¨atze: Betrachte z.B.max(a,b)odera+bvor und nach einem Schritt

I Wie entwickelt sich dieser Wert?

I Ista2b:amodb<ba/2

I Ista<2b:amodsb=abaa/2a/2

I Also:aschrumpft auf h ¨ochstens die H ¨alfte

I Außerdem: Nach dem Schritt istbgr ¨oßergleich dem neuena

I Also: Im n ¨achsten Schritt schrumpftbauf h ¨ochstens die H ¨alfte

I Zusammen: Nach zwei Schritten ista+bum mindestens den Faktor 2 geschrumpft!

I Wie oft kann eine Ganzzahl sich halbieren, bis 1 herauskommt?

Anzahl der Schleifendurchl ¨aufe ist beschr ¨ankt durch 2 log2(a+b)

29

(80)

Ubung: Datenstrukturen ¨

I Zur L ¨osung eines gegebenen Problems kann es verschieden effiziente Algorithmen geben

I Oft wesentlich: Geschickte Organisation der Daten durch geeignete Datenstrukturen

I Ubung: Finden Sie die zu den 5 Namen in Spalte 1 geh ¨orende¨ Ziffernfolge inListe 1. Stoppen Sie Ihre Zeit!

Spalte 1 Dummy 1 Dummy 2 Dummy 3 Dummy 4 Dummy 5

Spalte 2

Mcdonald, Jeffrey Palmer, Katie Pierce, Jaime Schmidt, Tami French, Erica

Spalte 3 Sims, Helen Obrien, Kim Curry, Courtney Brewer, Marcella Thornton, Dwight

30

(81)

Ubung: Datenstrukturen ¨

I Zur L ¨osung eines gegebenen Problems kann es verschieden effiziente Algorithmen geben

I Oft wesentlich: Geschickte Organisation der Daten durch geeignete Datenstrukturen

I Ubung: Finden Sie die zu den 5 Namen in Spalte 1 geh ¨orende¨ Ziffernfolge inListe 1. Stoppen Sie Ihre Zeit!

Spalte 1 Stone, Jo Pierce, Jaime Nunez, Glenda Hawkins, Mona Massey, Harold

Spalte 2

Mcdonald, Jeffrey Palmer, Katie Pierce, Jaime Schmidt, Tami French, Erica

Spalte 3 Sims, Helen Obrien, Kim Curry, Courtney Brewer, Marcella Thornton, Dwight

30

(82)

Ubung: Datenstrukturen ¨

I Zur L ¨osung eines gegebenen Problems kann es verschieden effiziente Algorithmen geben

I Oft wesentlich: Geschickte Organisation der Daten durch geeignete Datenstrukturen

I Ubung: Finden Sie die zu den 5 Namen in Spalte 2 geh ¨orende¨ Ziffernfolge inListe 2. Stoppen Sie Ihre Zeit!

Spalte 2

Mcdonald, Jeffrey Palmer, Katie Pierce, Jaime Schmidt, Tami French, Erica

Spalte 3 Sims, Helen Obrien, Kim Curry, Courtney Brewer, Marcella Thornton, Dwight

30

(83)

Ubung: Datenstrukturen ¨

I Zur L ¨osung eines gegebenen Problems kann es verschieden effiziente Algorithmen geben

I Oft wesentlich: Geschickte Organisation der Daten durch geeignete Datenstrukturen

I Ubung: Finden Sie die zu den 5 Namen in Spalte 3 geh ¨orende¨ Ziffernfolge inListe 3. Stoppen Sie Ihre Zeit!

Spalte 2

Mcdonald, Jeffrey Palmer, Katie Pierce, Jaime Schmidt, Tami French, Erica

Spalte 3 Sims, Helen Obrien, Kim Curry, Courtney Brewer, Marcella Thornton, Dwight

30

(84)

Datenstrukturen?

I Liste 1: Unsortiertes Array

I Lineare Suche

I Liste 2: Sortiertes Array

I Bin ¨are Suche (oder auch auch

“gef ¨uhlteInterpolationssuche”)

I Liste 3: Sortiertes Array mit pre-Hashing

I Ditto, aber mit besserem Einstiegspunkt

Wahl der geeigneten Datenstruktur erm ¨oglicht bessere/effizientere Suche!

“Bad programmers worry about the code. Good programmers worry about data structures and their relationships.”

— Linus Torvalds

31

(85)

Datenstrukturen?

I Liste 1: Unsortiertes Array

I Lineare Suche

I Liste 2: Sortiertes Array

I Bin ¨are Suche (oder auch auch

“gef ¨uhlteInterpolationssuche”)

I Liste 3: Sortiertes Array mit pre-Hashing

I Ditto, aber mit besserem Einstiegspunkt

Wahl der geeigneten Datenstruktur erm ¨oglicht bessere/effizientere Suche!

“Bad programmers worry about the code. Good programmers worry about data structures and their relationships.”

— Linus Torvalds

31

(86)

Komplexit ¨at

32

(87)

Komplexit ¨at von Algorithmen

I Fragestellung: Wieteuerist ein Algorithmus?

I Konkreter:

I Wie viele (elementare) Schritte braucht er f ¨ur einen gegebene Eingabe?

I Wie viel Speicherplatz braucht er f ¨ur einen gegebene Eingabe?

I Allgemeiner:

I Wie viele elementare Schritte braucht ein Algorithmus f ¨ur Eingaben einer bestimmten L ¨ange?

I . . . im Durchschnitt?

I . . . schlimmstenfalls?

I Wie viel Speicher braucht ein Algorithmus f ¨ur Eingaben einer bestimmten L ¨ange?

I . . . im Durchschnitt?

I . . . schlimmstenfalls?

33

Referenzen

ÄHNLICHE DOKUMENTE

Handelt eine Frau also tatsäch- lich verantwortungslos, wenn sie das unterernährte Kind nicht täglich zum feeding center bringt, so wie es ihr vom Personal des feeding center

Datensätze partitioniert in (paarweise disjunkte) Mengen, wobei jede Menge durch einen in ihr enthaltenen Datensatz repräsentiert

Datensätze partitioniert in (paarweise disjunkte) Mengen, wobei jede Menge durch einen in ihr enthaltenen Datensatz repräsentiert

From left to right, prostate magnetic resonance imaging (MRI) sequences diffusion- weighted T2-weighted images, fused PET/MRI and representative pathology map with biopsy results

6 Shop till you drop 9 Mengenangaben 6 Mit Wörtern umgehen 91. Revision and Self-check

I Wie viele elementare Schritte braucht ein Algorithmus f¨ur Eingaben einer bestimmten

Allerdings sind im Satz von Ceva die relevanten Verhältnisse

loomustada järgmiselt: antud värsi kõrgeimalt tasandilt on enamasti üks element, mis kujuneb teisi elemente otseselt või kaudselt alistavaks värsi tipuks; madalamailt tasanõeüt