An C++ implementation of quick sort using std::list.
The code is as follow:
#include
temp = iter;
using namespace std;
typedef list
void quicksort(list
ITER iter = end;
ITER begin = middle;
if(middle == end) {
return;
}
else{
--iter;
}
ITER temp;
while(iter != middle){
if(*iter < *middle){
--iter;
begin = seq->insert(begin,*temp);
seq->erase(temp);
}
else{
--iter;
}
}
quicksort(seq,begin,middle);
quicksort(seq,++middle,end);
}
Comments