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.
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/13 15:04:19 by dkaiser #+# #+# */
-/* Updated: 2024/04/16 17:54:16 by dkaiser ### ########.fr */
+/* Updated: 2024/04/17 09:30:37 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
{
int i;
int size;
+ int ctr;
i = 0;
+ ctr = 0;
size = data->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))