implement c++ Quicksort using median of 3
#ifndef QSORT_H
#define QSORT_H
#include
#include
using namespace std;
template
T median_of_three(T& a, T& b, T& c, TComparator
comparator) {
}
template
size_t partition(vector& vec, TComparator& comparator,
size_t low, size_t high) {
// TODO: implement.
}
template
void QuickSort(vector& vec, TComparator comparator,size_t
low,size_t high) {
if(comparator(low,high)){
size_t loc = partition(vec,comparator,low,high);
QuickSort(vec,comparator,low,loc-1);
QuickSort(vec,comparator,loc+1,high);
}
return;
}
template
void quicksort(vector& vec, TComparator comparator) {
// TODO: implement.
size_t size = vec.size();
QuickSort(vec,comparator,0,size-1);
}
#endif
test_case:...