From: Dominik Kaiser Date: Wed, 17 Apr 2024 07:48:09 +0000 (+0200) Subject: Change to 3-way radixsort X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=c0537681539794755df7b0be610b0fa7706411ba;p=42%2Fpush_swap.git Change to 3-way radixsort Instead of splitting into 2 sets, radixsort will split into 3. Currently one set is half and the other two each a quarter. Probably the efficiency could be increased by 3 equal partitions. Will look into that later. --- diff --git a/sorting.c b/sorting.c index 422625e..215f4a4 100644 --- a/sorting.c +++ b/sorting.c @@ -6,7 +6,7 @@ /* By: dkaiser a->size; while (i < size) { if (data->a->size && ((data->a->stack[0] >> bit) & 1) == 0) - run_command(data, PB); + { + if (((data->a->stack[0] >> bit )& 2) == 0) + run_command(data, PB); + else + { + run_command(data, PB); + run_command(data, RB); + ctr++; + } + } else if (data->a->size > 1) run_command(data, RA); i++; } + while (ctr--) + { + run_command(data, RRB); + run_command(data, PA); + } while (data->b->size > 0) run_command(data, PA); if (!is_sorted(data->a))