Präsentation herunterladen
Veröffentlicht von:Irmingild Schmieder Geändert vor über 10 Jahren
1
Präsentation der Arbeitsweise des Sortieralgorithmus Quicksort
2
10 11 9 1 6 2 5 3 7 8 4 i=0 j=11 wert=0 wert ist das partitionierende Element. Der grüne Zeiger wandert von links nach rechts. Er bleibt stehen, sobald er eine Zahl gefunden hat, die größer als wert ist. Der rote Zeiger wandert von rechts nach links. Er bleibt stehen, sobald er eine Zahl gefunden hat, die kleiner oder gleich wert ist. Dann werden die Zahlen an den Positionen des grünen und roten Zeigers miteinander vertauscht – größere Zahlen als wert wandern damit von links nach rechts, kleinere Zahlen als wert wandern damit von rechts nach links. Quicksort
3
10 11 9 1 6 2 5 3 7 8 4 i=0 j=10 wert=0 Quicksort
4
10 11 9 1 6 2 5 3 7 8 4 i=0 j=9 wert=0 Quicksort
5
10 11 9 1 6 2 5 3 7 8 4 i=0 j=8 wert=0 Quicksort
6
10 11 9 1 6 2 5 3 7 8 4 i=0 j=7 wert=0 Quicksort
7
10 11 9 1 6 2 5 3 7 8 4 i=0 j=6 wert=0 Quicksort
8
10 11 9 1 6 2 5 3 7 8 4 i=0 j=5 wert=0 0 und 10 tauschen nun die Plätze – große Zahlen nach rechts, kleine Zahlen nach links. Quicksort
9
11 9 1 6 10 2 5 3 7 8 4 i=1 j=4 wert=0 Quicksort
10
11 9 1 6 10 2 5 3 7 8 4 i=1 j=3 wert=0 Quicksort
11
11 9 1 6 10 2 5 3 7 8 4 i=1 j=2 wert=0 Quicksort
12
11 9 1 6 10 2 5 3 7 8 4 i=1 j=1 wert=0 Quicksort
13
11 9 1 6 10 2 5 3 7 8 4 j=0 i=1 wert=0 Sobald die Zeiger sich überlaufen, ist ein Durchlauf fertig. Neu partitionieren, wobei es nur einen rechten Teil gibt. Quicksort
14
11 9 1 6 10 2 5 3 7 8 4 i=1 j=11 wert=2 Der grüne Zeiger wandert von links nach rechts. Er bleibt stehen, sobald er eine Zahl gefunden hat, die größer als wert ist. Der rote Zeiger wandert von rechts nach links. Er bleibt stehen, sobald er eine Zahl gefunden hat, die kleiner oder gleich wert ist. Dann werden die Zahlen an den Positionen des grünen und roten Zeigers miteinander vertauscht – größere Zahlen als wert wandern damit von links nach rechts, kleinere Zahlen als wert wandern damit von rechts nach links. Quicksort
15
11 9 1 6 10 2 5 3 7 8 4 i=1 j=10 wert=2 Quicksort
16
11 9 1 6 10 2 5 3 7 8 4 i=1 j=9 wert=2 Quicksort
17
11 9 1 6 10 2 5 3 7 8 4 i=1 j=8 wert=2 Quicksort
18
11 9 1 6 10 2 5 3 7 8 4 i=1 j=7 wert=2 Quicksort
19
11 9 1 6 10 2 5 3 7 8 4 i=1 j=6 wert=2 2 und 11 tauschen nun die Plätze – große Zahlen nach rechts, kleine Zahlen nach links. Quicksort
20
2 9 1 6 10 11 5 3 7 8 4 i=2 j=5 wert=2 Quicksort
21
2 9 1 6 10 11 5 3 7 8 4 i=2 j=4 wert=2 Quicksort
22
2 9 1 6 10 11 5 3 7 8 4 i=2 j=3 wert=2 Quicksort
23
2 1 9 6 10 11 5 3 7 8 4 j=2 i=3 wert=2 Neu partitionieren: linker Teil von 1 bis 2 mit wert=2, rechter Teil von 3 bis 11 mit wert=5. Quicksort
24
2 1 9 6 10 11 5 3 7 8 4 i=1 j=2 i=3 j=11 wert=2 wert=5 Quicksort
25
1 2 4 6 10 11 5 3 7 8 9 j=1 i=2 i=4 j=10 wert=2 wert=5 Neu partitionieren ist links nicht mehr möglich. Quicksort
26
1 2 4 6 10 11 5 3 7 8 9 i=4 j=9 wert=5 Quicksort
27
1 2 4 6 10 11 5 3 7 8 9 i=4 j=8 wert=5 Quicksort
28
1 2 4 3 10 11 5 6 7 8 9 i=5 j=7 wert=5 Quicksort
29
1 2 4 3 5 11 10 6 7 8 9 i=6 j=6 wert=5 Quicksort
30
1 2 4 3 5 11 10 6 7 8 9 j=5 i=6 wert=5 Neu partitionieren: linker Teil von 3 bis 5 mit wert=3, rechter Teil von 6 bis 11 mit wert=6. Quicksort
31
1 2 4 3 5 11 10 6 7 8 9 i=3 j=5 i=6 j=11 wert=3 wert=6 Quicksort
32
1 2 4 3 5 11 10 6 7 8 9 i=3 j=4 i=6 j=10 wert=3 wert=6 Quicksort
33
1 2 3 4 5 11 10 6 7 8 9 j=3 i=4 i=6 j=9 wert=3 wert=6 Neu partitionieren: Linke Seite: linker Teil nicht möglich, rechter Teil von 4 bis 5 mit wert=4. Rechte Seite läuft noch weiter. Quicksort
34
1 2 3 4 5 11 10 6 7 8 9 i=4 j=5 i=6 j=8 wert=4 wert=6 Quicksort
35
1 2 3 4 5 6 10 11 7 8 9 i=4 j=4 i=7 j=7 wert=4 wert=6 Quicksort
36
1 2 3 4 5 6 10 11 7 8 9 j=3 i=5 j=6 i=7 wert=4 wert=6 Neu partitionieren: beide linke Teile nicht möglich, rechter Teil von 7 bis 11 mit wert=7. Quicksort
37
1 2 3 4 5 6 10 11 7 8 9 i=7 j=11 wert=7 Neu partitionieren: beide linke Teile nicht möglich, rechter Teil von 7 bis 11 mit wert=7. Quicksort
38
1 2 3 4 5 6 10 11 7 8 9 i=7 j=10 wert=7 Quicksort
39
1 2 3 4 5 6 10 11 7 8 9 i=7 j=9 wert=7 Quicksort
40
1 2 3 4 5 6 7 11 10 8 9 i=8 j=8 wert=7 Quicksort
41
1 2 3 4 5 6 7 11 10 8 9 j=8 i=8 wert=7 Neu partitionieren: linker Teil nicht möglich, rechter Teil von 8 bis 11 mit wert=10. Quicksort
42
1 2 3 4 5 6 7 11 10 8 9 i=8 j=11 wert=10 Quicksort
43
1 2 3 4 5 6 7 9 10 8 11 i=9 j=10 wert=10 Quicksort
44
1 2 3 4 5 6 7 9 8 10 11 j=9 i=10 wert=10 Neu partitionieren: linker Teil von 8 bis 9 mit wert=9, rechter Teil von 10 bis 11 mit wert=10. Quicksort
45
1 2 3 4 5 6 7 9 8 10 11 i=8 j=9 i=10 j=11 wert=10 Quicksort
46
1 2 3 4 5 6 7 8 9 10 11 j=8 i=9 i=10 j=10 wert=10 Neu partitionieren ist links nicht mehr möglich. Quicksort
47
1 2 3 4 5 6 7 8 9 10 11 j=9 i=11 wert=10 Fertig! Quicksort
Ähnliche Präsentationen
© 2024 SlidePlayer.org Inc.
All rights reserved.