I was wondering if this implementation of quicksort could be improved. Are there any things that I have done wrong?
template<typename Element>
size_t partition_quickSort(Element arr[], size_t start, size_t end) {
auto pivot = arr[end];
size_t index_partition = start;
for (size_t i = start; i < end; ++i) {
if (arr[i] <= pivot) {
std::swap(arr[index_partition++], arr[i]);
}
}
std::swap(arr[index_partition], arr[end]);
return index_partition;
}
template<typename Element>
void quick_sort(Element arr[], size_t start, size_t end) {
if (start < end) {
size_t partition = partition_quickSort(arr, start, end);
quick_sort(arr, start, partition - 1);
quick_sort(arr, partition + 1, end);
}
}
template<typename Element>
void quick_sort(Element arr[], size_t size) {
quick_sort(arr, 0, size - 1);
}