考研

您现在的位置: 查字典公务员网 >考研 >考试题库 >考研专业课 >考研计算机数据结构测试题(五)答案

考研计算机数据结构测试题(五)答案

2015-01-28 01:01:57
查字典公务员网

一、选择题

1.D 2.A 3.A 4.A 5.D

6.D 7.B 8.A 9.C 10.B

11.C 12.A 13.B 14.D 15.B

二、判断题

1.错 2.对 3.对 4.对 5.错

6.错 7.对 8.错 9.对 10.对

三、填空题

1. 1. O(n)

2. 2. s-next=p- p-next=s

3. 3. (1,3,2,4,5)

4. 4. n-1

5. 5. 129

6. 6. F==R

7. 7. p-lchild==0p-rchild==0

8. 8. O(n2)

9. 9. O(nlog2n), O(n)

10. 10. 开放定址法,链地址法

四、算法设计题

1. 1. 设计在顺序有序表中实现二分查找的算法。

struct record {int key; int others;};

int bisearch(struct record r[ ], int k)

{

int low=0,mid,high=n-1;

while(low=high)

{

mid=(low+high)/2;

if(r[mid].key==k) return(mid+1); else if(r[mid].keyk) high=mid-1; else low=mid+1;

}

return(0);

}

2. 2. 设计判断二叉树是否为二叉排序树的算法。

int minnum=-32768,flag=1;

typedef struct node{int key; struct node *lchild,*rchild;}bitree;

void inorder(bitree *bt)

{

if (bt!=0) {inorder(bt- if(minnumkey)flag=0; minnum=bt-inorder(bt-}

}

3. 3. 在链式存储结构上设计直接插入排序算法

void straightinsertsort(lklist *head)

{

lklist *s,*p,*q; int t;

if (head==0 || head-next==0) return;

else for(q=head,p=head-p!=0;p=q-next)

{

for(s=head;s!=q-s=s-next) if (s-p-data) break;

if(s==q-next)q=p;

else{q-next=p- p-next=s- s- t=p-p-data=s-s-}

}

}

查看全部

 推荐文章

 猜你喜欢

 附近的人在看

 推荐阅读

 拓展阅读

 最新资讯

 热门

 相关资讯

 猜你喜欢

返回顶部