Algorithm
Algorithm
Selection Sort
Insertion Sort
for (i=1; i<N; i++) {
tmp = array[i];
j=i;
while(j>0 && tmp<array[j-1]){
array[j] = array[j-1];
j--;
}
array[j]=tmp;
}
Quick Sort
function quicksort('array'){
if length('array') ≤ 1
return 'array' // an array of zero or one elements is already sorted
select and remove a pivot element 'pivot' from 'array' // see 'Choice of pivot' below