The
Quicksort Quick-Line
voidQuickSort (int[] L,intLeftintRight ) { if(left<Right )intpivotpos=partion (l,left,right); QuickSort (L,lefft,pivotpos-1); QuickSort (L,pivotpos+1, rigth);}intPartitionint[] L,intLowintHigh ) { intpivotpos=Low ; intpivot=L[low]; for(inti=low+1;i<=high;i++) if(l[i]<pivot) {Pivot++; if(pivotpos!=i) Swap (L[i],l[pivotpos]); } L[low]=l[pivotpos];l[pivotpos]=pivot; returnPivotpos;}
No2:
Bubblesort (Bubble sort)
Bubblesort (int v[],int n) { for(intint=1;i<n;i++ ) for (int j=n-1;j>=i;j--) if(v[j-1]>v[j]) { int temp=v[j-1]; V[j-1]=v[j]; V[J]=temp; } }
No3:
MergeSort (merge sort)
voidMergeSort (int[] L,intLen) { intl2[]=New int[Len]; Recmergesort (L,L2,0,len-1);}voidRecmergesort (int[] L,int[] L2,intLeftintRight ) { intMid= (left+right)/2; Recmergesort (L,l2,left,mid); Recmergesort (L,l2,mid+1, right); Merge (l,l2,left,mid,right);}voidMergeint[] L,int[] L2,intLeftintMidintRight ) { for(intk=left;k<=right;k++) {L2[k]=L[k]; ints1=left,s2=mid+1,t=Left ; while(s1<=mid&&s2<=Right )if(L[s2]<=l[s1]) l[t++]=l2[s1++]; Elsel[t++]=l2[s2++]; while(S1<=mid) l[t++]=l2[s1++]; while(s2<=right) l[t++]=l2[s2++]; }}
No4:
BinarySearch (two-point search)
int BinarySearch (int[] l,int x,int low,int high ) { int mid=0 ; if (low<= high) { Mid= (Low+high)/2; if (X>l[mid]) Mid=binaryseaech (l,c,mid+1, high); Else if (X<l[mid]) Mid=binaryseaech (l,c,low,mid+1); } return mid;}
NO5:
Heapsort (Heap sort)
And more .....
Java implementation of various sorts