diff options
| author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-10-27 00:28:51 +0000 |
|---|---|---|
| committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-10-27 00:28:51 +0000 |
| commit | e3863557f5762735bc2c911f94a96a84dae2d8f5 (patch) | |
| tree | 261ddedad7fa20511e667426d31a763b8e3c86ff /impls | |
| parent | 8ee90f0d06baf15f4779c705c1e2863d586ba375 (diff) | |
| download | algorithms-e3863557f5762735bc2c911f94a96a84dae2d8f5.tar.gz algorithms-e3863557f5762735bc2c911f94a96a84dae2d8f5.tar.bz2 algorithms-e3863557f5762735bc2c911f94a96a84dae2d8f5.zip | |
Some cleanup of qsort and vec
Diffstat (limited to 'impls')
| -rw-r--r-- | impls/qsort.cpp | 20 | ||||
| -rw-r--r-- | impls/vec.c | 2 |
2 files changed, 10 insertions, 12 deletions
diff --git a/impls/qsort.cpp b/impls/qsort.cpp index d3e8c1d..a230456 100644 --- a/impls/qsort.cpp +++ b/impls/qsort.cpp @@ -33,13 +33,12 @@ void quicksort(int *arr, int arr_size) print_arr(arr, arr_size); printf("\n"); #endif - // Optimisation: for small arr_size, a different sort like the - // bubble sort may be better, instead of initialising new stack - // frames. + // TODO Optimisation: for small arr_size, a different sort like the bubble + // sort may be better, instead of initialising new stack frames. if (arr_size < 2) return; - // Optimisation: Use some heuristics to figure out a better pivot - // than some constant choice of element. + // TODO Optimisation: Use some heuristics to figure out a better pivot than + // some constant choice of element. int pivot = 0; int pivot_value = arr[0]; for (int i = 1; i < arr_size; ++i) @@ -57,13 +56,12 @@ void quicksort(int *arr, int arr_size) print_arr(arr, arr_size); printf("\n"); #endif - // Optimisation: Use a stack to do this instead of recursion. + // TODO Optimisation: Use a stack to do this instead of recursion. // - // This algorithm is similar to a pre order traversal/dfs, in this - // case on an array where left and right partition are children - // nodes to the original array node. Also with recursion there's a - // real risk for very large ARR_SIZE of running out of space in the - // call stack. + // This algorithm is similar to a pre order traversal/dfs, in this case on an + // array where left and right partition are children nodes to the original + // array node. Also with recursion there's a real risk for very large + // ARR_SIZE of running out of space in the call stack. if (pivot != 0) quicksort(arr, pivot); if (pivot < arr_size - 1) diff --git a/impls/vec.c b/impls/vec.c index f73b9fc..442b1cf 100644 --- a/impls/vec.c +++ b/impls/vec.c @@ -16,7 +16,7 @@ @brief A vector, consisting of a header and some payload (data). @details The idea is that the user must never actually interact with this structure directly, only the data involved. Any vector related functions - deal with + will take the pointer to the data and look behind it to get the header. */ typedef struct { |
