0607数据结构试题A答案.docx

上传人:b****5 文档编号:6869560 上传时间:2023-01-11 格式:DOCX 页数:13 大小:250.59KB
下载 相关 举报
0607数据结构试题A答案.docx_第1页
第1页 / 共13页
0607数据结构试题A答案.docx_第2页
第2页 / 共13页
0607数据结构试题A答案.docx_第3页
第3页 / 共13页
0607数据结构试题A答案.docx_第4页
第4页 / 共13页
0607数据结构试题A答案.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

0607数据结构试题A答案.docx

《0607数据结构试题A答案.docx》由会员分享,可在线阅读,更多相关《0607数据结构试题A答案.docx(13页珍藏版)》请在冰豆网上搜索。

0607数据结构试题A答案.docx

0607数据结构试题A答案

 

系主任审批并签名

教研室主任审批并签名

刘顺海

A卷

拟题人

刘顺海

广州大学松田学院2006~2007学年考试卷(答案)

课程:

数据结构考试形式(闭卷)

专业:

计算机科学与技术准考证号:

姓名:

题次

-一-

-二二

总分

分数

16

10

14

30

30

100

评卷人

填空题(每空1分,共计16分)

1.

装订线{此线外不能答题

数据(Data)是人们利用文字符号、数字符号以及其他规定的符号对现实世界的事物及其活动的抽象描述。

2.下面程序段的时间复杂度是_0(n*m)_。

For(i=0;i

For(j=0;j

A[i][j]=0;

3.在一个循环顺序队列Q中,判断队空的条件为front==rear,判断队满的条

件为(rear+1)%QueueMaxSize==front。

4.若已知一棵二叉树的深度为k(k>1),则这棵树至多有2k-1个结点,这棵

树的第i(1

二叉树,则k与n的关系为k=匚log2n」+1。

5.中缀算术表达式3+4/(25-(6+15))*8所对应的波兰算术表达式

为3425615+-/8*+。

6.一个有向图中有1000个顶点,1000条边,则形成的邻接矩阵有1000个非

零元素,因此是稀疏矩阵。

7.每次从待排序的区间中选择出具有最小排序码的元素,把该元素与该区间的第

一个元素交换位置,此种排序方法叫做亠直接选择排序;使两个有序表

合并成一个有序表的排序方法叫做_二路归并排序。

8.对于下图1,请写出其一种拓扑序列的结果:

0,1,。

 

9.向线性表中满足条件的位插入一个元素是voidInsert(List&L,const

Elimtype&item)。

在下面的程序段中,假定线性表La的类型为List,元素类

型ElemType为int,并假定每个程序段是连续执行的,则程序段执行后所得到

的线性表La为:

26、34、48、57、62、79。

InitList(La);

inta[]={48,26,57,34,62,79};

for(i=0;i<6;i++)Insert(La,a[i]);

TraverseList(La);

10.假定一组记录的排码为(46,79,56,38,40,84),则利用堆排序方法建立的初始

堆为(84,79,56,38,40,46)。

选择题(在每小题的四个备选答案中,选出一个正确的答案,并将其代码填入题干后的括号内。

每小题1分,共计10分)

1.一个数组元素a[i]的另一种等价表示方式为(A)

A*(a+i)Ba+iC*a+iD&a+I

2.链栈与顺序栈相比,有一个较明显的优点是(A)

A通常不会出现栈满的情况B通常不会出现栈空的情况

C插入操作更加方便D删除操作更加方便

3.若查找表中的记录按关键字的大小顺序存放在一个一维数组中,用二分法(折

半法)查找的平均搜索长度为(B)

2

A0(n)B0(log2n)C0(nlog2n)D0((log2n))

4.在一个单链表HL中,若要向表头插入一个由指针p指向的结点,则执行(B)

A.HL=p;p->next=HL;

C.p->next=HL;p=HL;

D.p->next=HL->next;HL->next=p;

5.下列广义表中是线性表的只有(C)

A.E(a,(b,c))B.E(a,E)C.E(a,b)D.E(a,L())

6.设线性链表中结点的结构为(data,link)。

已知指针p所指结点不是尾结点,若

在p指针指向的结点之后插入s指针指向的结点,则应执行以下哪个操作

(C)

As->link:

=p;p->link:

=sBs->link:

=p->link;p:

=s;

Cs->link:

=p->link;p->link:

=s;Dp->link:

=s;s->link:

=p;

7.设图中有n个顶点和e条边,进行深度优先搜索遍历的时间复杂度至多为(A)。

A.O(n+e)B.0(n*e)C.O(nlog2n)D.(elog2e)

8.采用折半查找方法进行查找,数据文件应为且限于(A)。

A.有序表顺序存储结构B.有序表链式

存储结构

C.随机表顺序存储结构D.随机表链

式存储结构

9.若已知一棵二叉树先序序列为ABCDEF,中序序列为CBDAEGF则其后序序列为

(A)。

ACDBGFEABCDBFGEACCDBAGFEDBCDAGFE

10.对于含有n个顶点和e条边的无向连通图,利用普里姆(Prim)算法产生最小生

成树,其时间复杂度为(D)。

2

A。

O(n)B.0(n*e)C.O(nlog2n)D.(elog2e)

判断题(下列各题,你认为正确的,请在前面的括号内打",错误的打X。

每小题2分,共计14分)

1.(X)在单链表中,要取得某个元素,只要知道该元素指针即可,因此单链表是随机存储结构。

2.(V)线性表若采用链式存储表示时所有存储单元的地址可连续可不连续。

3.(X)删除二叉排序树中一个结点,再重新插入上去,一定能得到原来的二叉排序树。

4.

(V)任一AOV网中至少有一条关键路径,且是从源点到汇点的路径中最长的一条。

5.(V)在索引顺序表上实现分块查找(BlockingSearch属于索引查找),

在等概率查找情况下,其平均查找长度不仅与表的个数有关,而且与每一块中

的元素个数有关。

6.(X)图G由两个集合V(G)和E(G)所组成,其中顶点集V(G)能为空

集,而边集E(G)不能为空。

7.(X)只有在初始数据为逆序,冒泡排序所执行的比较次数最多。

四、综合题(每小题6分,共计30分)

1.有一组关键码序列{23,20,30,15,17,45,18},画图给出建堆过程的每个步骤。

2.

1.

3.

列出右图所示二叉树的叶结点、分支结点和每个结点的层次。

(根结点的层次为0)

【解答】

二叉树的叶结点有⑥、⑧、⑨。

分支结点有①、②、③、④、⑤、⑦。

结点①的层次为0;结点②、③的层次为1;

结点④、⑤、⑥的层次为2;结点⑦、⑧的层次为3;结点⑨的层次为4。

4.设有序顺序表中的元素依次为017,094,154,170,275,503,509,512,553,612,

677,765,897,908。

试画出对其进行折半查找时的二叉排序树,并计算搜索成

功的平均搜索长度和搜索不成功的平均搜索长度。

【解答】

5.画出1个顶点、2个顶点、3个顶点、4个顶点和5个顶点的无向完全图。

试证明在n个顶点的无向完全图中,边的条数为n(n-1)/2。

【解答】

【证明】

在有n个顶点的无向完全图中,每一个顶点都有一条边与其它某一顶点相连,所以

每一个顶点有n-1条边与其他n-1个顶点相连,总计n个顶点有n(n-1)条边。

但在无向图中,顶点i到顶点j与顶点j到顶点i是同一条边,所以总共有n(n-1)/2条边。

6.在操作序列push

(1)、push

(2)、pop、push(5)、push(7)、pop、push(6)之后,栈顶元素和栈底元素分别是什么?

并画出执行过程。

(push(k)表示整数k入

7.

栈,pop表示栈顶元素出栈)

(c)pop,push(6)

(a)push

(1),push

(2)(b)pop,push(5),push(7)

五、算法设计题(共计30分)

1.设计一个算法,从线性表中删除表头元素。

下面已经给出程序的大体内容,请

完善之。

(其中有4个空缺,每空3分,共12分)

ElemtypeDeleteFront(List&L)

{

if(L.size==0){

cerr<<”Deletingfromanemptylist!

”<

exit

(1);

}

Elemtypetemp=L.list[0];

For(inti=1;i

Lilst[i-1]=L.list[il;

L.size--;

Returntemp;

}

2.设有一个表头指针为h的单链表。

试设计一个算法,通过遍历一趟链表,将链表中所有结点的链接方向逆转,如下图所示。

要求逆转结果链表的表头指针h

指向原链表的最后一个结点。

(其中有4个空缺,每空3分,共12分)

templatevclassType>voidList:

:

Inverse(){

if(first==NULL)return;

ListNode*p=first->link,*pr=NULL;

while(p!

=NULL){

pr=first;

first=p;

p=p->link;〃指针前移

}

first->link=pr;

}

3.若用二叉链表作为二叉树的存储表示,试以二叉树为参数,交换每个结点的左

子女和右子女问题,编写递归算法:

(其中有3个空缺,每空2分,共6分)

voidBinaryTree:

:

exchange(BinTreeNode*ptr){

BinTreeNode*temp;

if(ptr->leftChild!

=NULL||ptr->rightChild!

=NULL){

temp=ptr->leftChild;

ptr->leftChild=ptr->rightChild;

ptr->rightChild=temp;

exchange(ptr->leftChild);

exchange(ptr->rightChild):

}

Whenyouareoldandgreyandfullofsleep,

Andnoddingbythefire,takedownthisbook,

Andslowlyread,anddreamofthesoftlook

Youreyeshadonce,andoftheirshadowsdeep;

Howmanylovedyourmomentsofgladgrace,

Andlovedyourbeautywithlovefalseortrue,

Butonemanlovedthepilgrimsoulinyou,

Andlovedthesorrowsofyourchangingface;

Andbendingdownbesidetheglowingbars,

Murmur,alittlesadly,howlovefled

Andpaceduponthemountainsoverhead

Andhidhisfaceamidacrowdofstars.

Thefurthestdistaneeintheworld

Isnotbetweenlifeanddeath

ButwhenIstandinfrontofyou

Yetyoudon'tknowthat

Iloveyou.

Thefurthestdistaneeintheworld

IsnotwhenIstandinfrontofyou

Yetyoucan'tseemylove

Butwhenundoubtedlyknowingthelovefromboth

Yetcannotbetogether.

Thefurthestdistaneeintheworld

Isnotbeingapartwhilebeinginlove

ButwhenIplainlycannotresisttheyearning

Yetpretendingyouhaveneverbeeninmyheart.

Thefurthestdistaneeintheworld

Isnotstrugglingagainstthetides

Butusingone'sindifferentheart

Todiganuncrossableriver

Fortheonewholovesyou.

Whenyouareoldandgreyandfullofsleep,

Andnoddingbythefire,takedownthisbook,

Andslowlyread,anddreamofthesoftlook

Youreyeshadonce,andoftheirshadowsdeep;

Howmanylovedyourmomentsofgladgrace,

Andlovedyourbeautywithlovefalseortrue,

Butonemanlovedthepilgrimsoulinyou.

Andlovedthesorrowsofyourchangingface;

Andbendingdownbesidetheglowingbars,

Murmur,alittlesadly,howlovefled

Andpaceduponthemountainsoverhead

Andhidhisfaceamidacrowdofstars.

Thefurthestdistaneeintheworld

Isnotbetweenlifeanddeath

ButwhenIstandinfrontofyou

Yetyoudon'tknowthat

Iloveyou.

Thefurthestdistaneeintheworld

IsnotwhenIstandinfrontofyou

Yetyoucan'tseemylove

Butwhenundoubtedlyknowingthelovefromboth

Yetcannotbetogether.

Thefurthestdistaneeintheworld

Isnotbeingapartwhilebeinginlove

ButwhenIplainlycannotresisttheyearning

Yetpretendingyouhaveneverbeeninmyheart.

Thefurthestdistaneeintheworld

Isnotstrugglingagainstthetides

Butusingone'sindifferentheart

Todiganuncrossableriver

Fortheonewholovesyou.

Whenyouareoldandgreyandfullofsleep,

Andnoddingbythefire,takedownthisbook,

Andslowlyread,anddreamofthesoftlook

Youreyeshadonce,andoftheirshadowsdeep;

Howmanylovedyourmomentsofgladgrace,

Andlovedyourbeautywithlovefalseortrue,

Butonemanlovedthepilgrimsoulinyou.

Andlovedthesorrowsofyourchangingface;

Andbendingdownbesidetheglowingbars,

Murmur,alittlesadly,howlovefled

Andpaceduponthemountainsoverhead

Andhidhisfaceamidacrowdofstars.

Thefurthestdistaneeintheworld

Isnotbetweenlifeanddeath

ButwhenIstandinfrontofyou

Yetyoudon'tknowthat

Iloveyou.

Thefurthestdistaneeintheworld

IsnotwhenIstandinfrontofyou

Yetyoucan'tseemylove

Butwhenundoubtedlyknowingthelovefromboth

Yetcannotbetogether.

Thefurthestdistaneeintheworld

Isnotbeingapartwhilebeinginlove

ButwhenIplainlycannotresisttheyearning

Yetpretendingyouhaveneverbeeninmyheart.

Thefurthestdistaneeintheworld

Isnotstrugglingagainstthetides

Butusingone'sindifferentheart

Todiganuncrossableriver

Fortheonewholovesyou.

Whenyouareoldandgreyandfullofsleep,

Andnoddingbythefire,takedownthisbook,

Andslowlyread,anddreamofthesoftlook

Youreyeshadonce,andoftheirshadowsdeep;

Howmanylovedyourmomentsofgladgrace,

Andlovedyourbeautywithlovefalseortrue,

Butonemanlovedthepilgrimsoulinyou.

Andlovedthesorrowsofyourchangingface;

Andbendingdownbesidetheglowingbars,

Murmur,alittlesadly,howlovefled

Andpaceduponthemountainsoverhead

Andhidhisfaceamidacrowdofstars.

Thefurthestdistaneeintheworld

Isnotbetweenlifeanddeath

ButwhenIstandinfrontofyou

Yetyoudon'tknowthat

Iloveyou.

Thefurthestdistaneeintheworld

IsnotwhenIstandinfrontofyou

Yetyoucan'tseemylove

Butwhenundoubtedlyknowingthelovefromboth

Yetcannotbetogether.

Thefurthestdistaneeintheworld

Isnotbeingapartwhilebeinginlove

ButwhenIplainlycannotresisttheyearning

Yetpretendingyouhaveneverbeeninmyheart.

Thefurthestdistaneeintheworld

Isnotstrugglingagainstthetides

Butusingone'sindifferentheart

Todiganuncrossableriver

Fortheonewholovesyou.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1