#include #include //here is implementation of 6 main sorting algorithm ; data part is integer which is easily //extendable //source code is free and is avaiable via public domain under GPL license //all codes tested by gcc 3.32 from gnu and i used dev-c++ 4.9.7.0 for developing //by masoud kalali 21-22 jan 2003 //sorting algorithms implementation void BubbleSort(int a[],int size){ int switched = 1; int hold; for(int i=0;ia[j+1] ){ switched = 1; hold = a[j]; a[j] = a[j+1]; a[j+1] = hold; } } } void SelectionSort(int a[],int size){ for(int i = size;i>0;i--){ int large = a[0]; int indx = 0; for(int j = 1;j <= i;j++) if(a[j]>large ){ large = a[j]; indx = j; } a[indx] = a[i]; a[i] = large; } } void InsertionSort(int a[],int size){ int i,j; int e; for(i=1;i=0 && a[j]>(e);j--) a[j+1] = a[j]; a[j+1] = e; } } //an aray implementation of heapsort void HeapSort(int a[],int size){ int i,f,s; for(i=1;i 0 && a[f]>(e) ){ a[s] = a[f]; s = f; f = (s-1)/2; } a[s] = e; } for(i=size;i>0;i--){ int value = a[i]; a[i] = a[0]; f = 0; if(i == 1) s = -1; else s = 1; if(i > 2 && a[2]>(a[1])) s = 2; while(s >= 0 && value<(a[s])){ a[f] = a[s]; f = s; s = 2*f+1; if(s+1 <= i-1 && a[s]<(a[s+1]) ) s = s+1; if(s > i-1) s = -1; } a[f] = value; } } //array implementation of merge sort void MergeSort(int x[], int n) { long aux[8],i,j,k,L1,L2,size,U1,U2; size = 1; while (size x && j>left) --j; if (i<=j) { temp=a[i]; a[i]=a[j]; a[j]=temp; ++i; --j; } } while(i<=j); if (left