From c0537681539794755df7b0be610b0fa7706411ba Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Wed, 17 Apr 2024 09:48:09 +0200 Subject: [PATCH] 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. --- sorting.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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)) -- 2.47.2