Download presentation
Presentation is loading. Please wait.
Published byJessica Coleman Modified over 10 years ago
1
Quicksort nach Hoare
2
Liste von int-Werten 7675888604182774986 4975841608882777686
3
4975841608882777686 60 4975841 8882777686 7495841 7677828886
4
60 4975841 8882777686 7495841 7677828886 7 60 77 495841 76 828886 494158 76 828688
5
7 58607677 88 49 41 8286 4149 8286 7 60 77 495841 76 828886 494158 76 828688
6
7 58607677 88 49 41 8286 4149 8286 7 495860767782 88 41 86 41 86
7
7 495860767782 88 41 86 41 86 7414958607677828688
8
public static void quickSort(int[] liste){ int untereGrenze = 0; int obereGrenze = liste.length-1; quickSort(liste, untereGrenze,obereGrenze); }
9
private static void quickSort(int[] liste, int untereGrenze, int obereGrenze) { int links = untereGrenze; int rechts = obereGrenze; int pivot = liste[((untereGrenze + obereGrenze) / 2)]; do { while (liste[links] < pivot) { links++; } while (pivot < liste[rechts]) { rechts--; } if (links <= rechts) { int tmp = liste[links]; liste[links] = liste[rechts]; liste[rechts] = tmp; links++; rechts--; } } while (links <= rechts); if (untereGrenze < rechts) liste = quickSort(liste, untereGrenze, rechts); if (links < obereGrenze) liste = quickSort(liste, links, obereGrenze); }
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.