void BiInsertSort(RecType R[]int n)
{//二路插入排序的算法
int d[n+]; //辅助存储
d[]=R[];first=;final=;
for(i=;i<=n;i++)
{ if(R[i]key>=d[]key) //插入后部
{ low=;high=final;
while (low<=high) //折半查找插入位置
{ m=(low+high)/;
if(R[i]key< d[m]key) high=m; else low=m+;
}//while
for (j=final;j>=high+;j) d[j+] = d[j];//移动元素
d[high+]=R[i]; final++; //插入有序位置
}
else //插入前部
{ if(first==){ first=n; d[n]=R[i];}
else{ low=first;high=n;
while (low<=high)
{ m=(low+high)/;
if(R[i]key< d[m]key) high=m; else low=m+;
}//while
for (j=first;j<=high;j++) d[j] = d[j]; //移动元素
d[high]=R[i]; first;
}//if
}//if
}//for
R[] =d[fisrt];
for(i=first%n+j=;i!=fisrt;i=i%n+j++) R[j] =d[i]; //将序列复制回去
}//BiInsertSort
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []