#include "sorts.h" template void Swap(T& a,T& b) { T temp; temp=a; a=b; b=temp; } // a generic bubble sort // it is not the most efficient way to do it template void Bubble( X* data,int size ) { register int a,b; X t; for(a=1; a < size ; a++) for(b=size-1; b >= a; b--) if(data[b-1] > data[b]) Swap(data[b-1],data[b]); } // a generic exchangesort // it is not the most efficient way to do it template void ExchangeSort(X* data,int size) { int i,j; //to make size-1 ways //take a minimum from a[i+1] ... a[size-1] and place into a[i] for(i=0; i data[j]) Swap(data[i],data[j]); } template void InsertionSort(T *data,int size) { int i,j; T temp; for(i=1; i0 && temp < data[j-1]) { //to move the elements right for the insertion of temp data[j] = data[j-1]; j--; } data[j]=temp; } } template void SelectionSort(T* data,int size) { int small,i,j; for(i=0; i< size-1; i++) { small=i; for(j=i+1; j void BubbleSort( X *data,int size ) { // i index of the last element in the sublist int i,j,lastExchange; i=size-1; // make htis process till no swaps were done while(i>0) { lastExchange=0; //initialization to permite the stop of process // working on sublist data[0] -- data[i] for(j=0; j