<pre name= "code" class= "CPP" > Exchange class Sort: 1: Bubble sort O (n^2), Space complexity O (1) 2: Quick sort O (n multiplied by log with 2 base, n logarithm), spatial complexity O (log with 2 base, n logarithm)// Bubble sort void Bubblesort (int r[],int n) {int i,j,tmp,flag;for (i=0;i<n-1;i++) {flag=0;for (j=n-1;j>i;j--) {if (R[j]< R[j-1]) {tmp=r[j]; R[J]=R[J-1]; R[j-1]=tmp;flag=1;}} if (flag==0) return;}} Quick sort void QuickSort (int r[],int s,int t) {int i=s,j=t;int tmp;if (s<t) {tmp=r[s];while (i!=j) {while (J>i && R[J]>TMP) j--; R[i]=r[j];while (i<j && r[i]<tmp) i++; R[j]=r[i];} r[i]=tmp;//the last [i] gave to others, the value here is not used, to hold the benchmark value quicksort (R,S,I-1); QuickSort (r,i+1,t);}} Fast sort non-recursive algorithm void QuickSort (int r[],int n) {int i,j,low,high,top=-1;int temp;struck{int low;int High;} st[maxitem];top++; st[top].low=0; St[top].high=n-1;while (top>-1) {//Out of Stack low=st[top].low;high=st[top].high;top--;i=low;j=high;if (Low
Exchange class Sort: bubbling, fast (recursive vs. non-recursive)