完成下列折半插入排序算法。 Void binasort(struct node r[MAXSIZE],int n) {for(i=2;i<=n;i++){ r[0]=r[i];low=1;high=i-1; while(low<=high){ mid=(low+high)/2; if(r[0].key else low=mid+1 ; } for(j=i-1;j>=low;j- -)r[j+1]=r[j] ; r[low]=() ; } }
在下面冒泡排序算法中填入適當(dāng)內(nèi)容,以使該算法在發(fā)現(xiàn)有序時(shí)能及時(shí)停止。 bubble(R) Rectype R[n]; {int i,j,exchang; Rectype temp; i=1; do {exchang=False; for(j=n;j>=¬¬i+1 ;j- -) if(R[j] {temp=R[j-1]; R[j-1]=R[j]; R[j]=temp; exchang=True ; } () ; }while(exchang=False ); }