diff options
Diffstat (limited to 'impls/qsort.cpp')
| -rw-r--r-- | impls/qsort.cpp | 20 |
1 files changed, 9 insertions, 11 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) |
