diff options
| author | Thomas Schmucker <ts@its1.de> | 2024-09-06 21:10:21 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2024-09-06 21:10:21 +0200 |
| commit | 9e8caf1e06ba7510160305da11a30d91dcfc23e5 (patch) | |
| tree | 30da0c941191d0907abe829feb1bf75f0fca4b3a /src/quicksort.c | |
| parent | 4ecdad9462c4447c1370cf1dd1341b2289c28566 (diff) | |
| download | data-structures-9e8caf1e06ba7510160305da11a30d91dcfc23e5.tar.gz data-structures-9e8caf1e06ba7510160305da11a30d91dcfc23e5.tar.bz2 data-structures-9e8caf1e06ba7510160305da11a30d91dcfc23e5.zip | |
reformat source code
Diffstat (limited to 'src/quicksort.c')
| -rw-r--r-- | src/quicksort.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/quicksort.c b/src/quicksort.c index 4657dcd..0b20ab9 100644 --- a/src/quicksort.c +++ b/src/quicksort.c | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | #include <time.h> | 4 | #include <time.h> |
| 5 | 5 | ||
| 6 | #include "util.h" | ||
| 7 | |||
| 8 | static int | 6 | static int |
| 9 | bigrand(void) | 7 | bigrand(void) |
| 10 | { | 8 | { |
| @@ -124,7 +122,7 @@ quickSort(int arr[], int low, int high) | |||
| 124 | { | 122 | { |
| 125 | while ( low < high ) { | 123 | while ( low < high ) { |
| 126 | /* pi is partitioning index, arr[p] is now | 124 | /* pi is partitioning index, arr[p] is now |
| 127 | at right place */ | 125 | at right place */ |
| 128 | int pi = partition(arr, low, high); | 126 | int pi = partition(arr, low, high); |
| 129 | 127 | ||
| 130 | if ( pi - low < high - pi ) { | 128 | if ( pi - low < high - pi ) { |
| @@ -299,6 +297,7 @@ heapsort_bu(T *data, int n) // zu sortierendes Feld und seine Länge | |||
| 299 | 297 | ||
| 300 | data[child] = val; // versickerten Wert eintragen | 298 | data[child] = val; // versickerten Wert eintragen |
| 301 | } | 299 | } |
| 300 | printf("%d\n", count); | ||
| 302 | } | 301 | } |
| 303 | 302 | ||
| 304 | /*----------------------------------------------------------------------*/ | 303 | /*----------------------------------------------------------------------*/ |
| @@ -356,7 +355,7 @@ bottom_up_heapsort(T r[], int n) | |||
| 356 | { | 355 | { |
| 357 | int k; | 356 | int k; |
| 358 | T x; | 357 | T x; |
| 359 | T * v; | 358 | T *v; |
| 360 | 359 | ||
| 361 | v = r - 1; /* The address shift */ | 360 | v = r - 1; /* The address shift */ |
| 362 | 361 | ||
| @@ -606,7 +605,7 @@ test_sorting(T a[], int n) | |||
| 606 | void | 605 | void |
| 607 | do_one_test(int n, void (*do_sort)(T a[], int n), void (*gen_testset)(T a[], int n)) | 606 | do_one_test(int n, void (*do_sort)(T a[], int n), void (*gen_testset)(T a[], int n)) |
| 608 | { | 607 | { |
| 609 | T * a; | 608 | T *a; |
| 610 | clock_t start, ende; | 609 | clock_t start, ende; |
| 611 | 610 | ||
| 612 | a = malloc(sizeof(T) * (size_t) n); | 611 | a = malloc(sizeof(T) * (size_t) n); |
| @@ -649,10 +648,10 @@ main(void) | |||
| 649 | do_all_tests("heapsort_bu", n, heapsort_bu); | 648 | do_all_tests("heapsort_bu", n, heapsort_bu); |
| 650 | do_all_tests("bottom_up_heapsort", n, bottom_up_heapsort); | 649 | do_all_tests("bottom_up_heapsort", n, bottom_up_heapsort); |
| 651 | do_all_tests("c_quicksort", n, c_quicksort); | 650 | do_all_tests("c_quicksort", n, c_quicksort); |
| 652 | //do_all_tests("g4g_quicksort", n, g4g_quicksort); | 651 | // do_all_tests("g4g_quicksort", n, g4g_quicksort); |
| 653 | //do_all_tests("sed_quicksort", n, sed_quicksort); | 652 | // do_all_tests("sed_quicksort", n, sed_quicksort); |
| 654 | do_all_tests("my_introsort", n, my_introsort); | 653 | do_all_tests("my_introsort", n, my_introsort); |
| 655 | //do_all_tests("my_quicksort", n, my_quicksort); | 654 | // do_all_tests("my_quicksort", n, my_quicksort); |
| 656 | do_all_tests("pp_quicksort", n, pp_quicksort); | 655 | do_all_tests("pp_quicksort", n, pp_quicksort); |
| 657 | do_all_tests("pp_quicksort_it", n, pp_quicksort_it); | 656 | do_all_tests("pp_quicksort_it", n, pp_quicksort_it); |
| 658 | 657 | ||
