|
C Fundamentals
Algorithms · data structures · cryptography · systems — pure C11, zero deps
|
LSD radix sort for non-negative ints, byte-by-byte. More...
Go to the source code of this file.
Macros | |
| #define | RADIX_BUCKETS 256 |
Functions | |
| static void | counting_pass (uint32_t *src, uint32_t *dst, size_t n, int byte_idx) |
| void | radix_sort_ints (int *arr, size_t n) |
LSD radix sort for non-negative ints, byte-by-byte.
Uses 4 passes (one per byte of a 32-bit int) of stable counting sort. Linear in n × bytes — i.e. effectively O(n) when the value range is bounded. Operates on unsigned int internally to keep the byte extraction unambiguous; assumes input is non-negative.
Returns silently without sorting if any value is negative — this is a teaching implementation, not a general-purpose replacement for quicksort.
Definition in file radix_sort.c.
| #define RADIX_BUCKETS 256 |
Definition at line 19 of file radix_sort.c.
|
static |
Definition at line 21 of file radix_sort.c.
References RADIX_BUCKETS.
Referenced by radix_sort_ints().
| void radix_sort_ints | ( | int * | arr, |
| size_t | n | ||
| ) |
Definition at line 38 of file radix_sort.c.
References counting_pass().