2012数据结构补考试卷A
湖北文理学院数据结构试题与答案A

湖北文理学院 2011-2012 学年度下学期《数据结构与算法》试卷A专业:计算机科学与技术姓名: 学号: 班级:一、判断题(本题共10小题,每小题1分,共计10分)。
(正确的打√,错的打×)1、顺序循环队列Q 空的条件是:Q.front==Q.rear.( )2、关键路径是始点到终点最小长度的路径。
( )3、序列(5, 6, 7, 20, 15, 8, 9, 25, 22,13)是一个堆。
( )4、在插入排序和选择排序中,若原始记录已基本有序,则较适合选用选择排序。
( )5、顺序表是随机存取,存取操作的时间为O (1)。
( )6、已知一棵二叉树的先序序列和后序序列,一定能构造出该二叉树。
() 7、有向图用邻接矩阵表示后,顶点i 的出度等于邻接矩阵中第i 行的元素个数。
( ) 8、归并排序的时间性能不随记录序列中关键字的分布而改变(与初始状态无关)。
( ) 9、在数据结构中,数据的基本单位是数据项。
()10、对任意一个图,从某顶点出发进行一次广度优先或深度优先遍历,可访问图的所有顶点。
( )二、填空题(本题共10小题,每小题 2 分,共计 20分)。
(请将正确答案填入空格内,答案是确定和唯一的)1、任意一棵具有n 个结点的二叉树,若它有m 个叶子,则该二叉树上度为1的结点数为_____个。
2、常用算法的描述方法有:自然语言 、 、 和流程图。
3、某二叉树的先根遍历序列为IJKLMNO ,中根遍历序列为JLKINMO ,则该二叉树中根结点的右孩子是 。
4、堆排序的时间复杂性为,空间复杂性为。
5、二维数组A[6,7],按行优先存储,每个元素占2个字节,A基址为600,则元素A[4,5]的存储地址是。
6、对广义表C=(a,(b,c,d))的运算 Tail(Tail(Head((Tail(C))))的结果是。
7、设有一组初始关键字值序列为(49,81,55,36,44,88),则利用快速排序的方法,以第一个关键字值为基准得到的一次划分为_________________________________________。
2012数据结构A卷

得 分 评分人贵州大学2011-2012学年第二学期考试试卷 A数据结构注意事项:1. 请考生按要求在试卷装订线内填写姓名、学号和年级专业。
2. 请仔细阅读各种题目的回答要求,在规定的位置填写答案。
3. 不要在试卷上乱写乱画,不要在装订线内填写无关的内容。
4. 满分100分,考试时间为120分钟。
题 号一二三四总 分统分人得 分一、单项选择题(共20分,每小题2分)1.不是四类基本逻辑结构之一的是 ( )A 、集合 B 、链表结构C 、树形结构 D 、网状结构2.关于队列的描述,错误的是 ( )A 、队列的头指针指下一个入队的位置B 、普通队列要求满足“先进先出”C 、使用一个队列可以模拟一个银行的多个同性质服务窗口的排队状况D 、循环队列可以采用顺序表实现3.在n 个结点的顺序表中,算法的时间复杂度是O (1)的操作是( )A 、访问第i 个结点(1≤i≤n )和求第i 个结点的直接前驱(2≤i≤n )B 、在第i 个结点后插入一个新结点(1≤i≤n )C 、删除第i 个结点(1≤i≤n )D 、将n 个结点从小到大排序4.下列关于串的叙述中,正确的是 ( )A 、一个串的字符个数即该串的长度B 、一个串的长度至少是1C 、空串是由一个空格字符组成的串得 分评分人D 、两个串S1和S2若长度相同,则这两个串相等5.稀疏矩阵一般的压缩存储方法有两种,即 ()A 、二维数组和三维数组B 、三元组和散列C 、三元组和十字链表D 、散列和十字链表6.按照二叉树的定义,具有3个结点的二叉树有 ()A 、3种B 、4种C 、5种 B 、6种7.不是图的存储结构的是 ( )A 、邻接多重表B 、十字链表C 、关联矩阵D 、可利用空间表 8.在关于动态存储管理,错误的说法是 ( )A 、未被占用的连续地址空间称为空闲块B 、可利用空间表一般采用链表C 、针对内存申请块的大小范围较广时,应该采用首次拟合法D 、针对内存申请块的大小较均匀时,应该采用最差拟合法9.理想情况下,速度最快的查找结构的是 ( )A 、分块索引B 、二叉排序树C 、二叉平衡树D 、哈希表10. 关于各种排序方法,错误的说法是 ( )A 、关键字大小相同的记录,排序后先后顺序不改变,则称为此排序为稳定的B 、内部排序算法的性能由关键字比较次数和记录移动次数决定C 、冒泡排序的时间复杂度为O(nlogn)D 、堆排序使用的堆对应一棵完全二叉树二、概念填空题(共20分,每空2分)1.若使用伙伴系统进行动态存储管理,若申请32个字,选中的空闲块有128个字,则这个空闲块会被分裂为__________个块(最小块大小可以为4)。
2012-2013数据结构

浙江大学2012–2013学年秋学期《数据结构基础》课程期末考试试卷(A) 课程号: 211C0020_,开课学院:_计算机科学与技术_考试试卷:√A卷、B卷(请在选定项上打√)考试形式:√闭、开卷(请在选定项上打√),允许带____无___入场考试日期: 2012 年 11 月 15 日,考试时间: 120 分钟诚信考试,沉着应考,杜绝违纪。
考生姓名:学号:所属院系: _Answer SheetNOTE: Please write your answers on the answer sheet.注意:请将答案填写在答题纸上。
I. Please select the answer for the following problems. (20 points)(1) Which one of the following statements is true as N grows?a. For any x , N x grows faster than !Nb. 2)(log N grows faster than Nc. 2log N grows faster than 2)(log Nd. N grows faster than 2)(log N N(2) What is the time complexity of the following function that computes X N ?long int Pow (long int X, unsigned int N) {if (N == 0) return 1;if (N == 1) return X;if (IsEven(N)) /* IsEven(N) returns 1 if N is even, or 0 otherwise */return Pow(X, N / 2) * Pow (X, N / 2);else return Pow(X * X, N / 2) * X;} a. O(N ) b. O(N log ) c. O(N N log ) d. O(N )(3) Suppose that N integers are pushed into and popped out of a stack. The input sequence is 1, 2, …, N and the output sequence is p 1, p 2, …, p N . If p 2 = 2, then p i (i>2) must be .a. ib. i+2c. N - id. cannot be determined(4) What is the major difference among lists, stacks, and queues? a. Lists use pointers, and stacks and queues use arraysb. Stacks and queues are lists with insertion/deletion constraintsc. Lists and queues can be implemented using circularly linked lists, but stacks cannotd. Stacks and queues are linear structures while lists are not(5) For an in-order threaded binary tree, if the pre-order and in-order traversal sequences are ABCDEF and CBAEDF respectively ,which pair nodes ’ right links are both threads?a. A and Bb. B and Dc. C and Dd. B and E(6) If N keys are hashed into the same slot, then to find these N keys, the minimum number of probes with linear probing is .a. N-1b. Nc. N(N+1)/2d. N+1(7) If an undirected graph with N vertices and E edges is represented by an adjacency matrix. How many zero elements are there in the matrix? a. E b. 2E c. N 2-E d. N 2-2E(8) If a directed graph is stored by an upper-triangular adjacency matrix –- that is, all the elements below the main diagonal are zero. Then its topological order .a. exists and must be uniqueb. exists but may not be uniquec. does not existd. cannot be determined(9)Sort a sequence of nine integers {4, 8, 3, 7, 9, 2, 10, 6, 5} by insertion sort. When 2 is moved to the first position, the number 8 must be at position (start from 1) .a. 4b. 5c. 6d. 7(10)Let T be a tree of N nodes created by union-by-height without path compression, then the depth of the tree isa. N/2b. O(logN)c. O(N2)d. O(1)II. Given the function descriptions of the following two (pseudo-code) programs, please fill in the blank lines. (21 points)(1)Bubble sort is a simple sorting algorithm. Suppose we have a list of integers and want to sort them in ascending order. Bubble sort repeatedly scans the list from the head to the tail, and swaps two adjacent numbers if they are in the wrong order. Please complete the following program to implement bubble sort. (12 points)struct node{int value;struct node *next;/* some other fields */}struct node BubbleSort (struct node *h){/* h is the head pointer of the list with a dummy head node */struct node *p, *q;int flag_swap;if (!h->next) return h;do{flag_swap = 0;p = h;while (p->next->next){if (① ){flag_swap++;q = p->next;② ;③ ;④ ;}else p = p->next;}} while (flag_swap > 0);return h;}(2)The function is to perform Find as a Union/Find operation with path compression. (9 points)SetType Find ( ElementType X, DisjSet S ){ElementType root, trail, lead;for ( root = X; S[ root ] > 0; ① );for ( trail = X; trail != root; ② ) {lead = S[ trail ] ;③ ;}return root ;}III. Please write or draw your answers for the following problems on the answer sheet. (44 points)(1) A sorting algorithm is stable if for any keys K i = K j for i < j,the corresponding records R i precedes R j in the sorted list.(a)Is Heap Sort stable? Please give a proof if your answer is“YES”, else please provide a counter example. (4 points)(b)Is Quick Sort stable? Please give a proof if your answer is“YES”, else please provide a counter example. (4 points)(2)Given the adjacency list representation of a directed graph.Suppose V1 is always the first vertex being visited. Please list(a)the depth-first search sequence; (5 points)(b)the breath-first search sequence; (5 points) and(c)the strongly connected components. (3 points)(3) A binary search tree is said to be of “type A”if all the keysalong the path from the root to any leaf node are in sorted order(either ascending or descending).(a)Given four keys {1, 2, 3, 4}, please draw all the possiblebinary search trees of type A. (4 points)(b)In general, given N keys {1, 2, …, N}, how many differentbinary search trees of type A can be constructed? (3 points)(4)Given a hash table of size 13 and the hash function H(key) = keymod 13. Assume that quadratic probing is used to solve collisions.Please fill in the hash table with input numbers {2, 15, 3, 16, 6,29, 24, 28}. (4 points)(5)Given eight keys {1, 2, …, 8}. Please do the following:(a)construct a complete binary tree which is also a binary searchtree; (5 points) and(b)construct a min-heap out of the array which stores thecomplete binary tree obtained from (a). Use BuildHeap with asequence of percolate-down’s. (4 points)(c)Observe the keys on each level of the min-heap obtained from(b). Is there a pattern of ordering? Is this true for moregeneral cases? (3 points)IV. Given a tree represented by left-child-right-sibling structure, please describe an algorithm that counts the number of leaf nodes on every level.(15 points)。
2012--数据结构英文试卷A及答案

北京交通大学软件学院2012―2013学年第一学期期末考试试题Data Structure and Algorithm Design(A)Class: ____Student Number: _____Name: ________ Teacher________I. Single-Choice(20 points)1. The height of a binary tree that contains 1023 elements is at most ( 1 )and at least ( 2 ).A.1022 B.1023 C.1024 D.9 E.10 F.112. If the sequence of pushing elements into a stack is a,b,c, which outputsequence is impossible?().A.abc B.bca C.cba D.cab3.How many minimum-cost spanning trees are there for an undirected connectedgraph with n vertices and e edges? ( )A. must be only oneB. n-1C. n-eD. not sure4. When using the adjacency matrix A to represent a undirected graph with n nodesand e edges, the degree of the node v i can be computed by formula ( ).A. B. /2 C. e /2 D.5. In the worst case, time complexity of quicksort will be degraded to ( ).A.O(n) B.O(n2) C.O(n log n)6.In order to find a specific key in an ordered list with 100 keys using binary searchalgorithm, the maximum times of comparisons is ( ).A. 25B.10C. 1D.77. Consider the following pseudo-code, which indicates part of a standard binary treealgorithm.print( node ){ print data;if( there is a left child ) print( left child );if( there is a right child ) print( right child );}Which of the following is the standard name for this algorithm? ( )A. Inorder traversalB. Preorder traversalC. Postorder traversalD. Binary search8.Which is not the property of a B-tree of order m? ( )A. The root node has m subtree at mostB. All leaf nodes are at the same level.C. The keys in every node are ordered.D. All leaf nodes are connected by links.9. Suppose that we have 1000 distinct integers, which are in the range from 0 to 50. If using Radix Sort according to the Least Significant Digit first, ( ) buckets are needed to constructed.A. 10B. 50C. 51D. 1000II. Fill in the blank (2points * 5)that of___ _ traversal algorithm for a normal tree.2. Here is a hash table, whose size is 18, hashing function isH1(key)=key%17 (% here is the modulus operator), and which usesLinear Probing strategy to cope with the collisions and inserts 26, 25, 72,38, 8, 18, 59 into the hash table in turn. The address of 59 is _ _ _.3. Given a key sequence {2,5,⑤,3}, please write its ascending orderedsequence after being sorted using heap sort. (Note 5=⑤, just 5 is before⑤in original sequence) . Please distinguish 5 and ⑤.4. If a 2-dimensions matrix A[m][n] is stored in an 1-D array withrow-major mapping, then the address of element A[i][j] relative toA[0][0] is ___ ____5. If the in-order and pre-order series of the nodes in a binary tree are“1,2,3,4,5” and “1,2,3,4,5” respectively, the p ostorder sequence shouldbe __________.III. (40 points)1. (8 points) Suppose there is a string abcadececdcdeeeded that comprisesthe characters a, b, c, d and e. We may encode the symbols usingvariable-length codes in order to make the length of string the shortest.Please draw the Huffman tree used to encode the characters, calculatethe weighted path length for the Huffman tree and write the code foreach character.(1)Draw the Huffman tree (3 points)a:2, b:1, c:4, d:5 , e: 6(3 points)(2)Calculate the weighted path length for the Huffman tree (2 points)WPL(T)= 6⨯2+5⨯2+2⨯3+1⨯3+4⨯2 =39(3)write the code for each character. (3 points) 错一个扣一分,扣光为止2. (8 points) Please respectively give two unsorted lists whose length are 4to illustrate that quick sort and selection sort are unstable.(1) An example list for quick sort and the sorting procedure using quicksort. (4 points)(4, 2, ②, 3)-------------------------- (2 points)sorting procedureThe first pass: 3,2,②,4 -------------------------(1point)The second pass: ②,2,3,4 -----------------------(1point)(2) An example list for selection sort and the sorting procedure usingselection sort. (4 points)(2,②,3,1)-------------------------- (1 points)sorting procedureThe first pass: 1,②, 3 , 2------------------------(1point)The second pass: 1,②, 3 , 2----------------------(1point)The third pass: 1,②, 2, 3 ----------------------(1point)3. (8 points) Given the key sequence (331, 166, 367, 236, 268, 137, 337,138), Please give the procedure (distributing and collecting) of sortingusing radix sort method. not necessary to write queue front and rearpointer if queue is null.(1) The first pass (3 points)(2) The second pass (3 points)(3)The third pass (2 points)4.(6 points)There are n1 nodes of degree 1,n2 nodes of degree 2,…,n m nodes of degree m in a tree of degree m,how many leaf nodes there are in the tree? Please give formula and prove your conclusion.Answer:because every node except root has one branch linked, so total nodes are equal to total branches plus one, there are n branches in node of degree n (2points)formula such as (2points)(2points)5. (10 points) Show the result of inserting { 63, 37, 48, 100, 54, 64, 27, 108, 99,42 } into(a) an empty binary search tree(2 points)(b) an initially empty A VL tree(4 points)(c) an initially empty B-tree of order 3(4 points)Answer:(1)(2)A VL (4 points)(3) B-tree (4points)IV. (10 points) Please fill in the blanks in the program which reverses a singly linked list. For example, {1,2,3,4,5,6,7,8,9,10} will become {10,9,8,7,6,5,4,3,2,1} after being reversed.#define list_init_size 100#define n 10#define len sizeof(struct node)typedef struct node{ int num; struct node *next; } lnode,*link;link llist;static int a[]={1,2,3,4,5,6,7,8,9,10};void creat(link *list)//create a singly linked list for key sequence stored in array a[]{ int i=0;lnode *p,*q;q=(struct node*)malloc(len);q->num=a[i]; *list=q;while (i<n-1){ p=(struct node*)malloc(len);i=i+1; (1);(2); q=p;}p->next=0;}void reverseList(link *h) // reverse the singly linked list{ lnode *p,*q, *r;p=*h; r=0;while (p){q=p; (3) ;(4) ; r = q;}(5) ;}main(){lnode *l;creat(&l); reverseList(&l);}Answer:(1) __ p->num=a[i];____(2) __ q->next=p;_______(3) __ p=p->next;_________(4) __ q->next =r;________(5) _ _*h=q;_________V.(10 points)Please read the following code, write the functions of programs and write output of the program.#include<stdio.h>#include "malloc.h"#define n 6static char ch[n]={'a','b','c','d','e','f'};static int a[n][n]={0,1,1,0,0,0, 1,0,0,1,1,0, 1,0,0,1,0,1, 0,1,1,0,0,1,0,1,0,0,0,1, 0,0,1,1,1,0};typedef struct node /*邻接表中的边结点*/{ int adjvex; struct node *next; } EdgeNode;typedef struct vnode /*邻接表中的顶点结点*/{ char vertex; EdgeNode *firstedge; } VertexNode[n];typedef struct{ int front,rear; int data[n]; } CirQueue;CirQueue *Q;int path[n],sum=0; int visited[n]; VertexNode G;void createALGraph() /*根据邻接矩阵,建无向网的邻接表表示*/ {int i,j; EdgeNode *s;for(i=0; i<n; i++){ G[i].vertex=ch[i]; G[i].firstedge=0; }for(i=0; i<n; i++){ for(j=0; j<n; j++){ if (a[i][j]==1){ s=(EdgeNode*)malloc(sizeof(EdgeNode));s->adjvex=j; s->next=G[i].firstedge;G[i].firstedge=s;}}}}void print(){ int i; EdgeNode *s;for (i=0; i<n; i++){ s=G[i].firstedge;printf(" %c : ",G[i].vertex);while(s){ printf(" %c",G[s->adjvex].vertex);s=s->next;}printf("\n");}}int ShortestPath(int u,int v)/* 求u和v之间经过的分支数最少的路径*/ { int k,pre[n],spath[n],count=0,found=0;EdgeNode * p;if(u==v) { printf("error\n"); return 0;}Q=(CirQueue*)malloc(sizeof(CirQueue));Q->front=Q->rear=0;for(k=0;k<n;k++) { visited[k]=0; pre[k]=-1;}visited[u]=1; Q->data[Q->rear++]=u;while(!found && Q->front!=Q->rear){ k=Q->data[Q->front++];p=G[k].firstedge;while(p && !found){ if(visited[p->adjvex]==0){ pre[p->adjvex]=k;if(p->adjvex==v) {found=1; break;}visited[p->adjvex]=1;Q->data[Q->rear++]=p->adjvex;}p=p->next;}}if(found){ printf("found: ");spath[count++]=v; k=pre[v];while(k!=u) {spath[count++]=k; k=pre[k];}spath[count]=u;for(k=count;k>=0;k--) printf("%d ", spath[k]);printf("\n"); return 1;}else{printf("There is no path\n"); return 0;}}main(){ int i,j;createALGraph(); print();for(i=0;i<n;i++) { visited[i]=0; path[i]=-1;} printf("\n");printf("The shotest path is "); i=ShortestPath(0,3);}Answer:(1)function of createALGraphCreate linked adjacency list based on adjacency matrix --------------------------------------- (2 points)(2)function of the whole programFind the shortest path which includes the minimum number of branches among all paths from u to v. ---------------------- (3 points)(3)output of the program. ------------------------------- (1+4=5 points)VI. (10 points) Please describe the children-sibling link of a tree in C Language. Write a function to calculate the depth of a normal tree. (10 points)Answer:Typedef struct CSNode (2分){ char data;struct CSNode *fch, *nsib;} CSNode, *CSTree;int TreeDepth(CSTree T){ if(!T) return 0; (2分)else { h1 = TreeDepth( T->fch ); (2分)h2 = TreeDepth( T->nsib); (2分)if(h1+1> h2) return(h1+1)else return(h2); (2分)}}。
2012安徽省数据结构试题及答案

C)loc(A1)+i*c+1 D)loc(A1)+(i+1)*c
6、栈进行插入和删除操作的特点是( A )。
A)LIFO B)FIFO
C)FCFS D)HPF
A) 5,4,3,2,1,6 B) 2,3,5,6,1,4
C) 3,2,5,4,1,6 D) 1A,采用压缩存储方式,以行序为主存储,a??11为第一个元素,其存储地址为1,每元素占1个地址空间,则a85的地址为( B )。
C)不含回路 D)有n条边
9、设单链表中指针p指向结点m,若要删除m之后的结点(若存在),则需修改指针的操作为( A )。
A)p->next=p->next->next; B) p=p->next;
C)p=p->next->next; D) p->next=p;
2、二叉树第i(i≥1)层上至多有( C )结点。
A)2i B)2i C)2i-1 D)2i-1
3、若某线性表最常用的操作是存取任一指定序号的元素和在最后进行插入和删除运算,则利用( D )存储方式最节省时间。
A)顺序表 B)双链表 C)带头结点的双循环链表 D)单循环链表
C) 3,2,5,4,1,6 D) 1,4,6,5,2,3
25、以下属于顺序存储结构优点的是( A )。
A) 存储密度大 B) 插入运算方便
C)删除运算方便 D)可方便地用于各种逻辑结构的存储表示
26、下面关于线性表的叙述中,错误的是哪一个?( D )
41、在一棵度为3的树中,度为3的结点个数为2,度为2的结点个数为1,则度为0的结点个数为( C )。
数据结构试卷A卷(含答案)

一、填空题(每空1分,共22分) 1、数据结构被形式地定义为(D, R),其中D是
的有限集合,R是
D上的 有限集合。 2、一个算法的效率可分为 效率和 效率。 3、向一个长度为n的向量的第i个元素(1≤i≤n+1)之前插入一个元素时, 需向后移动 ________个元素。 4、在一个循环队列中,队首指针指向队首元素的 位置。 5、在具有n个单元的循环队列中,队满时共有 个元素。 6、向栈中压入元素的操作是先 ,后 。 7、 称为空串; 称为空白串。 8、假设有二维数组A6×8,每个元素用相邻的6个字节存储,存储器按字 节编址。已知A的起始存储位置(基地址)为1000,则数组A的体积 (存储量)为 ;末尾元素A57的第一个字节地址为 ;若按行 存储时,元素A14的第一个字节地址为 ;若按列存储时,元素A47 的第一个字节地址为 。 9、设一棵完全二叉树具有1000个结点,则此完全二叉树有 个 叶子结点,有 个度为2的结点,有 个结点只有非空左子树, 有 个结点只有非空右子树。 10、线性有序表(a1,a2,a3,…,a256)是从小到大排列的,对一个给 定的值k,用二分法检索表中与k相等的元素,在查找不成功的情况下, 最多需要检索 次。设有100个结点,用二分法查找时,最大比较次数 是 。 11、散列法存储的基本思想是由 决定数据的存储地址。
6.假设用于通信的电文仅由8个字母组成,字母在电文中出现的频率分 别为0.07,0.19,0.02,0.06,0.32,0.03,0.21,0.10。试为这8个 字母设计哈夫曼编码。使用0~7的二进制表示形式是另一种编码方案。 对于上述实例,比较两种方案的优缺点。
五、算法设计(在下列算法的横线内填上适当的语句或表达式。) 1、直接选择排序 void selectsort (int R[ ] ) // 按递增序对R[ 0 ] ~R[n-1] 进行直接选择排序 { int i, j, k, temp ; for (i=0; i<= ; i++) { k=i ; for (j= ; j<=n-1; j++) if (R[ j ] R[ k ] ) k=j; if ( ) { temp=R[ i ]; R[ i ] = ; R[ k ]=temp; } } } 2、中序遍历二叉树 设二叉树用二叉链表表示,以t为根指针,二叉链表结点的类型为 node;栈s的元素类型为指向node的指针类型, 栈容量m足够大。中序遍 历的非递归算法如下: struct node {char data; node *lc,*rc; }; void preorder (node *t) { node *s[m] ,*p=t ; int top =- 1; do { while (p!=NULL) { s[++top] = } if (top!= -1) {p=s[top- -];
(完整word版)北师大数院11-12年数据结构试卷A+答案

北京师范大学2011~2012学年第 1 学期期末考试试卷(A 卷)课程名称: 数据结构 任课教师姓名: 刘玉铭卷面总分: 100 分 考试时长: 100 分钟 考试类别:闭卷 院(系): 数学科学学院 专 业: 年级: 2010 姓 名: 学 号:阅卷教师(签字):一、 单项选择题(每题2分,共10题20分)1.以下那一个术语与数据的存储结构无关? 。
A .栈B .哈希表C .线索树D .双向链表2.链表不具有的特点是 。
A .插入、删除不需要移动元素B .可随机访问任一元素C .不必事先估计存储空间D .所需空间与线性表长度成正比3.算术表达式a+b*(c+d/e )转为后缀表达式后为 。
装订线A.ab+cde/* B.abcde/+*+C.abcde/*++ D.abcde*/++4.二维数组A[10][20]采用列优先的存储方法,若每个元素占2个存储单元,设A[0][0]的地址为100,则元素A[7][6]的存储地址为。
A.232B.234C.390D.3925.若一棵二叉树具有10 个度为2 的结点,5 个度为1 的结点,则度为0 的结点个数是 .A.9B.11C.15D.不确定6.一棵二叉树中序序列为FE ABDC,后序序列为F BADC E,则层序序列为。
A。
ABCDEF B. EFCDBA C。
FECDAB D。
EFCDAB7.在有向图G 的拓扑序列中,若顶点Vi 在顶点Vj 之前,则下列情形不可能出现的是 .A.G 中有弧〈Vi,Vj>B.G 中有一条从Vi 到Vj 的路径C.G 中没有弧<Vi,Vj〉D.G 中有一条从Vj 到Vi 的路径8.对于二叉排序树,下面的说法是正确的。
A.二叉排序树是动态树表,查找不成功时插入新结点时,会引起树的重新分裂和组合B.对二叉排序树进行层序遍历可得到有序序列C.用逐点插入法构造二叉排序树时,若先后插入的关键字有序,二叉排序树的深度最大D.在二叉排序树中进行查找,关键字的比较次数不超过结点数的1/29.一组记录的关键字为{47、75、55、30、42、90},则用快速排序方法并以第一个记录为支点得到的第一次划分结果是 .A. 30,42,47,55,75,90B. 42,30,47,75,55,90C. 42,30,47,55,75,90D. 42,30,47,90,55,7510.下述文件中适合于磁带存储的是。
2012级数据结构试卷(A卷)

…………密…………封…………线…………内…………不…………要…………答…………题………………系 级 班 考生姓名 学号 任课教师姓名 第 选课教学班宜宾学院成人教育考试试卷(2011—2012学年第三学期) 课程名称:数据结构(A卷)说明:1、本试题共 ? 页 ? 大题,适用于2011级 班 考试时间:90分钟 一. 选择题(每题2分,共60分)1、研究数据结构就是研究( )。
A. 数据的逻辑结构B. 数据的存储结构C. 数据的逻辑结构和存储结构D. 数据的逻辑结构、存储结构及其基本操作 2、具有线性结构的数据结构是( )。
A. 图B. 树C. 广义表D. 栈 3、下面程序段的时间复杂度是( )。
for(i=0;i<m;i++) for(j=0;j<n;j++) a[i][j]=i*j;A. O(m 2)B. O(n 2)C. O(m*n)D. O(m+n) 4、若长度为n 的线性表采用顺序存储结构,在其第i 个位置插入一个新元素算法的时间复杂度( )。
A. O(log 2n)B.O(1)C. O(n)D.O(n 2) 5、链表不具有的特点是( )。
A. 可随机访问任一元素B. 插入删除不需要移动元素C. 不必事先估计存储空间D. 所需空间与线性表长度成正比6、在双向循环链表中,在p 指针所指的结点后插入一个指针q 所指向的新结点,修改指针的操作是( )。
A. p->next=q;q->prior=p;p->next->prior=q;q->next=q;B. p->next=q;p->next->prior=q;q->prior=p;q->next=p->next;C. q->prior=p;q->next=p->next;p->next->prior=q;p->next=q;D. q->next=p->next;q->prior=p;p->next=q;p->next=q;7、在一个长度为n 的顺序表中删除第i 个元素,需要向前移动( )个元素。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
中国矿业大学2011-2012学年
《数据结构》试卷(A卷)(考试时间:100分钟)
一. 填空(每空2分,共40分)
1. 数据结构式具有相同性质的数据元素的(1)。
2. 通常程序在调用另一个程序时,都需要使用一个(2)来保存被调用程序内分配的局部变量、形式参数的存储空间以及返回地址。
3. 有6行8列的二维数组A,每个元素用相邻的6个字节存储,存储器按字节编址,已知A的起始存储地址(基址)为1000,在行优先存储和列优先存贮情况下A[5,5]的存储地址分别为__(3)_____,_____(4)____。
4. 完全二叉树第4 个节点的父节点是第(5) 节点,左孩子是第(6) 个节点。
如果该二叉树有10层,则共有(7) 个节点。
5. 请描述在循环队列Q中,队头和队尾指针分别由front和rear表示,该队列有10个存储空间,判断队空和队满的条件分别分:_____(8)________,_______(9)_________。
6. 字符串t=”child”,s=”cake”,请写出下列函数的结果:StrLength(t) =(10)__;Concat(SubString(s,3,1),SubString(t,2,2))=____(11)___。
7. 一棵二叉树为
则后序序列为(12),中序序列为(13),先序序列为__(14)____。
8. 请用数据序列{53,17,12,66,58,70,87,25,56,60 }构造一棵二叉排序树_(15)_。
9.。
一个栈输入的序列式1,2,3,则可能的且以2为开头的输出序列是(16) ,不可能的序列是____(17)____。
10. 有n个结点的无向完全图的边数分别为_______(18)_______。
11. 要从数据:2,3,4,8,9,11,13查找11,若采用折半查找法,则在(19)次比较后,才找到该数据。
12. 在直接插入排序、希尔排序、冒泡排序和快速排序中,平均情况下(20)_____最快。
二简答题:
1给定{15,3,14,2,6,9,16,17},试为这8个数设计哈夫曼编码,并计算其带权路径长度。
2请对下图的无向带权图按克鲁斯卡尔算法求其最小生成树。
(要求使用图画出每一步过程)。
3 假定存在数据表:(3,4,5,7,24,30,54,63,72,87,95,102),请解决如下问题:
假设哈希函数为:H(key)=key mod 13,用该哈希函数将数据表存入长度为13的哈希表,(利用线性探测)请画出存放状态;
4 森林和二叉树的转换,画出和下列二叉树相应的森林
5
设要将序列(46,79,56,38,40,84)中的关键码按升序重新排列,写出快速排序的过程。
(每一步过程)
三程序题(10分)
编写算法判别给定二叉树是否为完全二叉树
一.填空(每空2分,共40分)
1. 集合。
2. 递归工作栈。
3. 1270 , 1210 。
4. 2, 8, 1023 。
5. Q.front==Q.rear, Q.front==(Q.rear+1)% 10 。
6. 5 , “iak”。
7. DECBHGFA, BDCEAFHG, ABCDEFGH
8. 。
9. 231 或213 , 312 。
10. n(n-1)/2 。
11. 2 。
12. 快速排序。
二. 简答题(每题10分,共50分)
1. 图不唯一WPL=229
2.
3.
4.
5.
(46,79,56,38,40,84)
(40,38,46,56,79,84)
(38,40,46,56,79,84)
三. 程序题(10分)
int IsFull_Bitree(Bitree T)//判断二叉树是否完全二叉树,是则返回1,否则返回0 { InitQueue(Q); flag=0;
EnQueue(Q,T); //建立工作队列 while(!QueueEmpty(Q)) { DeQueue(Q,p);
if(!p) flag=1; //如果孩子为空,则说明左孩子为空
else if(flag) return 0;
else
{
EnQueue(Q,p->lchild);
EnQueue(Q,p->rchild); //不管孩子是否为空,都入队列 }
}//while
return 1;
}//IsFull_Bitree。