当前位置:首页 > 数据结构(02331) > 正文内容

下面程序实现插入排序算法。在空白处填写适当的内容,使该程序功能完整。
typedefstruct{
intkey;
InfoTypeotherinfo;
}SeqList;
voidInsertSort(SeqListR[],intn)
{/*待排序列保存在R[1…n]中*/
SeqListx;
inti,j,k,lo,hi,mi;
for(i=2;i﹤=n;i++)


______;
l

高老师2年前 (2024-03-26)数据结构(02331)10

下面程序实现插入排序算法。在空白处填写适当的内容,使该程序功能完整。
typedefstruct{
intkey;
InfoTypeotherinfo;
}SeqList;
voidInsertSort(SeqListR[],intn)
{/*待排序列保存在R[1…n]中*/
SeqListx;
inti,j,k,lo,hi,mi;
for(i=2;i﹤=n;i++)


______;
lo=1;
hi=i一1;
while(lo<=hi)

mi=(lo+hi)/2;
if(______)break:
if(R[mi].key>x.key)hi=mi一1;
else10=mi+1;

if(mi==lo)k=i—mi;
elsek=i—mi一1;
for(j=0;j______;
R[i—j]=x;

x=R[i]; R[mi].key==x.key; R[i—j]=R[i—j一1]。

扫描二维码免费使用微信小程序搜题/刷题/查看解析。

版权声明:本文由翰林刷题小程序授权发布,如需转载请注明出处。

本文链接:https://doc.20230611.cn/post/432004.html

分享给朋友: