考研

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

计算机数据结构测试题(三)答案

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

一、选择题

1.C 2.C 3.C 4.B 5.B

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

二、判断题

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

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

三、填空题

1. 1. (49,13,27,50,76,38,65,97)

2. 2. t=(bitree *)malloc(sizeof(bitree)),bstinsert(t-rchild,k)

3. 3. p-next=s

4. 4. head-rlink,p-llink

5. 5. CABD

6. 6. 1,16

7. 7. 0

8. 8. (13,27,38,50,76,49,65,97)

9. 9. n-1

10. 10. 50

四、算法设计题

1. 1. 设计一个在链式存储结构上统计二叉树中结点个数的算法。

void countnode(bitree *bt,int count)

{

if(bt!=0)

{count++; countnode(bt-lchild,count); countnode(bt-rchild,count);}

}

2. 2. 设计一个算法将无向图的邻接矩阵转为对应邻接表的算法。

typedef struct {int vertex[m]; int edge[m][m];}gadjmatrix;

typedef struct node1{int info;int adjvertex; struct node1 *nextarc;}glinklistnode;

typedef struct node2{int vertexinfo;glinklistnode *firstarc;}glinkheadnode;

void adjmatrixtoadjlist(gadjmatrix g1[ ],glinkheadnode g2[ ])

{

int i,j; glinklistnode *p;

for(i=0;ii++) g2[i].firstarc=0;

for(i=0;ii++) for(j=0;jj++)

if (g1.edge[i][j]==1)

{

p=(glinklistnode *)malloc(sizeof(glinklistnode));p-adjvertex=j;

p-nextarc=g[i].firstarc; g[i].firstarc=p;

p=(glinklistnode *)malloc(sizeof(glinklistnode));p-adjvertex=i;

p-nextarc=g[j].firstarc; g[j].firstarc=p;

}

}

查看全部

 推荐文章

 猜你喜欢

 附近的人在看

 推荐阅读

 拓展阅读

 最新资讯

 热门

 相关资讯

 猜你喜欢

返回顶部