|
C Fundamentals
Algorithms · data structures · cryptography · systems — pure C11, zero deps
|
Quicksort using Lomuto partition. More...
Go to the source code of this file.
Functions | |
| static long | lomuto_partition_int (int *arr, long lo, long hi) |
| static long | lomuto_partition_str (char **arr, long lo, long hi) |
| static void | quicksort_int_recursive (int *arr, long lo, long hi) |
| void | quicksort_ints (int *arr, size_t n) |
| static void | quicksort_str_recursive (char **arr, long lo, long hi) |
| void | quicksort_strings (char **arr, size_t n) |
| static void | swap_int (int *a, int *b) |
| static void | swap_str (char **a, char **b) |
Quicksort using Lomuto partition.
Average O(n log n), worst O(n²) on already-sorted input. Tail-recursion on the smaller partition would bound the stack depth at O(log n) — kept straightforward here for readability.
Definition in file quicksort.c.
|
static |
Definition at line 55 of file quicksort.c.
References swap_int().
Referenced by quicksort_int_recursive().
|
static |
Definition at line 21 of file quicksort.c.
References swap_str().
Referenced by quicksort_str_recursive().
|
static |
Definition at line 68 of file quicksort.c.
References lomuto_partition_int(), and quicksort_int_recursive().
Referenced by quicksort_int_recursive(), and quicksort_ints().
| void quicksort_ints | ( | int * | arr, |
| size_t | n | ||
| ) |
Definition at line 76 of file quicksort.c.
References quicksort_int_recursive().
|
static |
Definition at line 34 of file quicksort.c.
References lomuto_partition_str(), and quicksort_str_recursive().
Referenced by quicksort_str_recursive(), and quicksort_strings().
| void quicksort_strings | ( | char ** | arr, |
| size_t | n | ||
| ) |
Definition at line 42 of file quicksort.c.
References quicksort_str_recursive().
Referenced by algo_from_name().
|
static |
Definition at line 49 of file quicksort.c.
Referenced by lomuto_partition_int().
|
static |
Definition at line 15 of file quicksort.c.
Referenced by lomuto_partition_str().