1、下列不属于线性结构的是: Which one of the followings does not belong to linear structure:(There is only one correct answer) A、队列(queue) B、散列表(hash table) C、向量(vector) D、图(graph)
2、以下哪种结构是逻辑结构,而与存储和运算无关: Which of the following structure is a logical structure regardless of the storage or algorithm:(There is only one correct answer) A、队列(queue) B、双链表(doubly linked list) C、数组(array) D、顺序表(Sequential list)
3、关于算法特性描述正确的有: Which one is right about algorithm’s characterization:(there are more than one correct answers) A、算法保证计算结果的正确性。Algorithm will ensure the correctness of the calculation results. B、组成算法的指令可以有限也可能无限。 Instructions which composite algorithms can be infinite or finite C、算法描述中下一步执行的步骤不确定。 The next step in the implementation of the algorithm described is uncertain. D、算法的有穷性指算法必须在有限步骤内结束。The finite nature of algorithms means algorithm must be completed within a limited step.
4、下列说法正确的是: Which options may be correct?(there are more than one correct answers) A、如果函数f(n)是O(g(n)),g(n)是O(h(n)),那么f(n)是O(h(n))【 if f(n) is O(g(n)),g(n) is O(h(n)),then f(n) is O(h(n))】 B、如果函数f(n)是O(g(n)),g(n)是O(h(n)),那么f(n)+g(n)是O(h(n))【if f(n) is O(g(n)),g(n) is O(h(n)),so f(n)+g(n) is O(h(n))】 C、如果a>b>1,是,但不一定是【if a>b>1, is , may not be 】 D、函数f(n)是O(g(n)),当常数a足够大时,一定有函数g(n)是O(af(n))【if f(n)是O(g(n)),When constant a is big enough ,there must be g(n) is O(af(n))】
5、已知一个数组a的长度为n,求问下面这段代码的时间复杂度: An array of a, its length is known as n. Please answer the time complexity of the following code.(There are more than one answers.) for (i=0,length=1;i<n-1;i++){ for (j = i+1;j<n && a[j-1]<=a[j];j++) if(length<j-i+1) length=j-i+1; } A、 B、 C、 D、
6、计算运行下列程序段后m的值: Calculate the value of m after running the following program segment n = 9; m = 0; for (i=1;i<=n;i++) for (j = 2*i; j<=n; j++) m=m+1; 求m的值
7、由大到小写出以下时间复杂度的序列: 答案直接写标号,如:(1)(2)(3)(4)(5) (提示:系统基于字符匹配来判定答案,所以您的答案中不要出现空格) Write the following time complexity in descending sequence:Write down the answer labels such as (1)(2)(3)(4)(5). (Hint:This problem is judged by string matching, Please make sure your answer don't contain any blanks. )
编程作业
1、两数求和
第二章 线性表
第二章 线性表测验
1、下面关于线性表的叙述中,正确的是哪些? Which of the followings about linear list are correct?(There are more than one answers.) Select the answer that matches A、线性表采用顺序存储,必须占用一片连续的存储单元。Linear lists use sequential storage which must occupy a continuous memory units. B、线性表采用顺序存储,便于进行插入和删除操作。Linear lists using sequential storage, it is easy to do insert and delete operations. C、线性表采用链接存储,不必占用一片连续的存储单元。Linear lists using the linked storage, do not occupy a continuous memory units. D、线性表采用链接存储,便于插入和删除操作。Linear lists using the linked storage, it is easy for insert and deleting operations.
2、下面的叙述中正确的是: Select the answer that matches (There are more than one correct answers) A、线性表在链式存储时,查找第i个元素的时间与i的数值无关。When the linear list stored in linked form, the time to find the i-th element is regardless of the value of i. B、线性表在顺序存储时,查找第i个元素的时间与i的数值成正比。When the linear list stored sequentially, the time to find the i-th element is proportional to value with i. C、线性表在顺序存储时,查找第i个元素的时间与i的数值无关。When the linear list stored sequentially, the time to find the i-th element is regardless of the value of i. D、线性表在链式存储时,插入第i个元素的时间与i的数值成正比。When linear lists stored in the linked form, the time to insert the i-th element is proportional to value with i.
3、完成在双循环链表结点p之后插入s的操作为: The operation to insert s after the doubly circular linked list’s node p is: (There are more than one answers.) A、p->next->prev=s; s->prev=p; s->next=p->next; p->next=s; B、p->next->prev=s; p->next=s; s->prev=p; s->next=p->next; C、s->prev=p; s->next=p->next; p->next=s; p->next->prev=s; D、s->next=p->next; p->next->prev=s; s->prev=p; p->next=s;
4、对于一个具有n个结点的单链表,在已知的结点*p后插入一个新结点的时间复杂度为O(___),在给定值为x的结点后插入一个新结点的时间复杂度为O(___)。(请依次填入,格式为(a)(b),如果您的答案中出现字母,请使用小写;后一空系统基于字符匹配来判定答案,所以您的答案中不要出现空格) For a single linked list with n nodes, and after a known node *p to insert a new node, the time complexity is O (___); after a given node with x value insert a new node, the time complexity is O (___). (If your answer contains letters, use lowercase one.The second blank is judged by string matching, Please make sure your answer don't contain any blanks. )
5、带头结点head的循环链表的尾结点tail的特点是: _____ (提示: 1.请使用“=” 2.系统基于字符匹配来判定答案,所以您的答案中不要出现空格) The circular linked list with a head node, its tail node’s character is: _____. (Hint:1. Please use "=" 2.This problem is judged by string matching, Please make sure your answer don't contain any blanks. )
第二章 线性表编程作业
1、字符串插入
2、约瑟夫问题
第二章 线性表编程作业
1、字符串插入
2、约瑟夫问题
第三章 栈与队列
第三章 栈与队列测验
1、设栈S 和队列Q 的初始状态为空,元素e1,e2,e3,e4,e5和e6依次通过栈S,一个元素出栈后即进队列Q,若6 个元素出队的序列是e2,e4,e3,e6,e5,e1则栈S的容量至少应该是_____________。 Assume that the stack S and queue Q’s initial state is empty, the elements e1, e2, e3, e4, e5 and e6 followed through stack S, an element out the stack means into the queue Q. If the sequence the six elements out of the queue is e2, e4, e3, e6, e5, e1 then stack S of capacity should be at least _____________. (There is only one correct answer) A、2 B、3 C、4 D、6
2、队列的特点包括: Queue’ features include:(There are more than one answers.) A、后进先出Last-in first-out (LIFO) B、先进后出First-in last-out (FILO) C、先进先出First-in first-out (FIFO) D、后进后出 Last-in last-out (LILO)
3、以下循环队列的实现方式中,长度为n的队列,所能容纳的元素个数也为n的有: In the following realizing ways of circular queue, the queue whose length is n can also contain the number of n elements is:(There are more than one answers.) A、只用front和rear两个指针标记队列的头和尾,两个指针均为实指Only use front and rear as the queue’s head and tail pointers and the two pointers are actually referring to. B、用front和rear两个指针标记队列的头和尾,并用整型变量len记录队列元素数With the queue’s head and tail pointers marked as front and rear, use the integer variable len to record the number of elements. C、用front和rear两个指针标记队列的头和尾,并用布尔型变量empty记录队列是否为空With the queue’s head and tail pointers marked as front and rear, use Boolean variable empty record whether the queue is empty. D、只用front和rear两个指针标记队列的头和尾,两个指针均为虚指Only use front and rear as the queue’s head and tail pointers and the two pointers are virtually referring to.
4、编号为1,2,3,4的四辆列车,顺序开进一个栈式结构的站台;则开出车站的顺序有______种可能。 注释:例如 1, 2, 3, 4 或 4, 3, 2,1 就是其中两种可能出站序列;而 4, 3, 1, 2 是 非法序列。 Numbered 1,2,3,4 four trains, orderly entered a stack structure station. How many possible leaving sequences of that four trains ? ______ . Note: For instance, the leaving sequence could be 1,2,3,4 or 4,3,2,1 these two possibilities, but 4, 3, 1, 2 is not a possible sequence.
5、双端队列可以在队列的两端进行插入和删除操作,既可在队尾进行插入/删除,又可在队头进行插入/删除。现有4个不同的元素顺序输入到双端队列,那么可以得到_____种不同的排列。 double-ended queue can insert and delete operations on both ends of the queue. That it can insert / delete at its tail, but also at the head. Existing 4 different elements sequentially input to the double-ended queue, you can get _____ different permutations.
栈与队列编程作业
1、中缀表达式求值
2、HTML
第五章 二叉树
编程作业
1、由中根序列和后根序列重建二叉树
2、表达式·表达式树·表达式求值
第六章 树
第六章 树测验
1、一个深度为h的满k叉树,最多有多少个叶结点?(独根树深度为0)(单选) There is a full k-ary tree, whose depth is h. How many leaf nodes can it have at most? (The depth of a tree, which only has a root node, is 0.)(There is only one correct answer) A、 B、 C、 D、
2、一个深度为h的满k叉树,最多有多少个结点?(独根树深度为0) There is a full k-ary tree, whose depth is h. How many nodes can it have at most? (The depth of a tree, which only has a root node, is 0.) A、 B、 C、 D、
3、设F是由T1,T2,T3三棵树组成的森林,其中T1,T2,T3的结点数分别为n1,n2和n3,与F对应的二叉树为B,则二叉树B的右子树中有_____________个结点(单选) Assume that F is a forest, made up of tree T1, T2, T3, and the node numbers of T1, T2, T3 are n1, n2, n3. Let B be the corresponding binary tree of F, then B's right sub-tree will has __________ nodes. (There is only one correct answer) A、n2 B、n3 C、n1+n3 D、n2+n3
4、设F是由T1,T2,T3三棵树组成的森林,其中T1,T2,T3的结点数分别为n1,n2和n3,与F对应的二叉树为B,则二叉树B的左子树中有_____________个结点(单选) Assume that F is a forest, made up of tree T1, T2, T3, and the node numbers of T1, T2, T3 are n1, n2, n3. Let B be the corresponding binary tree of F, then B's left sub-tree will has __________ nodes. (There is only one correct answer) A、n2-1 B、n3-1 C、n1-1 D、n2
5、将一棵树T转换为左子/右兄链表表示的二叉树B,则T的后根次序遍历序列是B的相应_________序列。(单选) Transform a tree T into a binary tree B, which is represented by Left-Child/Right-Sibling implementation. Then the post-order traversal sequence of T is the same as the __________ sequence of B.(There is only one correct answer) A、前序遍历 B、后序遍历 C、中序遍历 D、层次遍历
6、2-3树是一种特殊的树,它满足两个条件: (1)每个内部结点有两个或三个子结点; (2)所有的叶结点到根的路径长度相同; 如果一棵2-3树有9个叶结点,那么它可能有_________个非叶结点。 (多项) 2-3 tree is a special kind of tree, it satisfy: (1)Every internal node has 2 or 3 child nodes. (2)All the leaf nodes have the same length of the path to the root node. If a 2-3 tree has 9 leaf nodes, then it may have __________ non-leaf nodes.(There are more than one correct answers) A、4 B、5 C、6 D、7
7、给出一棵树的逻辑结构T=(N,R),其中:N={A,B,C,D,E,F,G,H,I,J,K} R={r} r={(A,B),(B,E),(B,F),(F,G),(F,H),(A,C),(C,I),(C,J),(J,K),(A,D)} Given a logical structure of a tree, T=(N, R), and N={A, B, C, D, E, F, G, H, I, J, K}, R={r}, r={(A,B), (B,E), (B,F), (F,G), (F,H), (A,C), (C,I), (C,J), (J,K), (A,D)} 试回答下列问题: Please answer these questions: (1)哪个是根结点?which is the root node? (2)哪些是F的孩子?which are the child nodes of Node F? (3)结点K的层次是多少? (注:根的层数为0,独根树深度为0,高度为1,其他题目同样如此;同一个选项的 答案如果有多个字母,按照字典序排列,且不要以空格分隔) (P.S. the level of the root node is 0, the depth of a tree, which only has a root node, is 0, and its height is 1. Other problems have the same regulations. If there are several alphabets in one question, order them by lexicographical order, and do not add spaces.)
8、给出一棵树的逻辑结构T=(N,R),其中: N={A,B,C,D,E,F,G,H,I,J,K} R={r} r={(A,B),(B,E),(B,F),(F,G),(F,H),(A,C),(C,I),(C,J),(J,K),(A,D)} 试回答下列问题: Given a logical structure of a tree, T=(N, R), and N={A, B, C, D, E, F, G, H, I, J, K}, R={r}, r={(A,B), (B,E), (B,F), (F,G), (F,H), (A,C), (C,I), (C,J), (J,K), (A,D)} Please answer these questions: (1)哪个是F的父结点?which is the parent node of Node F? (2)哪些是B的子孙?which are the offspring of Node B? (3)以结点C为根的子树的深度是多少?what is the depth of the sub-tree whose root node is Node C? (注:根的层数为0,独根树深度为0,高度为1,其他题目同样如此;各个选项之间的答案用空格分隔就好;同一个选项的答案如果有多个字母,按照字典序排列,且不要以空格分隔) (P.S. the level of the root node is 0, the depth of a tree, which only has a root node, is 0, and its height is 1. Other problems have the same regulations. If there are several alphabets in one question, order them by lexicographical order, and do not add spaces.)
9、给出一棵树的逻辑结构T=(N,R),其中: N={A,B,C,D,E,F,G,H,I,J,K} R={r} r={(A,B),(B,E),(B,F),(F,G),(F,H),(A,C),(C,I),(C,J),(J,K),(A,D)} 试回答下列问题: Given a logical structure of a tree, T=(N, R), and N={A, B, C, D, E, F, G, H, I, J,K}, R={r}, r={(A,B), (B,E), (B,F), (F,G), (F,H), (A,C), (C,I), (C,J), (J,K), (A,D)} Please answer these questions: (1)哪些是叶结点?which are the leaf nodes? (2)哪些是F的祖先?which is the parent node of Node F? (3)树的深度是多少?what is the depth of the tree? (注:根的层数为0,独根树深度为0,高度为1,其他题目同样如此;同一个小题的答案如果有多个字母,按照字典序排列,且不要以空格分隔,不同小题用一个空格隔开)
10、若一个具有N个顶点,K条边的无向图是一个森林(N>K且2K>=N),则该森林有多少棵树? There is an undirected graph. It has N nodes and K edges. (N>K and 2K>=N). If it is a forest, then how many trees will it has?
11、将下图的二叉树转换为对应的森林,按照先根次序列出其结点。(答案的字母之间没有空格) Transform this binary tree into the corresponding forest, and write down the pre-order node sequence. (Do not add spaces in your answer.)
12、将下图的二叉树转换为对应的森林,按照后根次序列出其结点。(答案的字母之间没有空格) Transform this binary tree into the corresponding forest, and write down the post-order node sequence. (Do not add spaces in your answer.)
13、一棵完全三叉树,下标为121的结点在第几层? (注:下标号从0开始,根的层数为0) In a complete 3-ary tree, what level is the node, whose subscript is 121, stand on? (P.S. the subscript starts form 0, and the level of root node is 0)
14、一棵完全三叉树,下标为120的结点在第几层? (注:下标号从0开始,根的层数为0) In a complete 3-ary tree, what level is the node, whose subscript is 120, stand on? (P.S. the subscript starts form 0, and the level of root node is 0)
15、根据树的双标记层次遍历序列,求其带度数的后根遍历序列 Given the double-tagging level-order traversal sequence of a tree, please write down the post-order traversal sequence with degree. 比如:已知一棵树的双标记层次遍历序列如下: For example, assume that a tree's double-tagging level-order traversal sequence is shown as followed:
16、根据树的双标记层次遍历序列,求其带度数的后根遍历序列 Given the double-tagging level-order traversal sequence of a tree, please write down the post-order traversal sequence with degree. 比如:已知一棵树的双标记层次遍历序列如下: For example, assume that a tree's double-tagging level-order traversal sequence is shown as followed:
17、根据树的双标记层次遍历序列,求其带度数的后根遍历序列 Given the double-tagging level-order traversal sequence of a tree, please write down the post-order traversal sequence with degree.
18、对于以下等价类,采用“加权合并规则”(也称“重量权衡合并规则”),进行并查运算,给出最后父节点索引序列。 For the following equivalence class, please use "weighted union rule" and UNION/FIND algorithm to write down the final parent node index sequence. 4-0 6-2 8-4 9-4 3-5 9-5 5-2 1-2 7-1 注意:当合并大小相同的两棵树的时候,将第二棵树的根指向第一棵树的根;根节点的索引是它本身;数字之间用空格隔开。 Notice: When we join two trees with the same size, we let the root of the second tree point to the root of the first tree. The index of the root node is itself. Separate the numbers with only one spaces.
19、对于以下等价类,采用“加权合并规则”(也称“重量权衡合并规则”),进行并查运算,给出最后父节点索引序列。 For the following equivalence class, please use "weighted union rule" and UNION/FIND algorithm to write down the final parent node index sequence. 8-9 3-2 7-4 5-9 6-1 8-6 7-3 2-5 8-0 注意:当合并大小相同的两棵树的时候,将第二棵树的根指向第一棵树的根;根节点的索引是它本身;数字之间用空格隔开。 Notice: When we join two trees with the same size, we let the root of the second tree point to the root of the first tree. The index of the root node is itself. Separate the numbers with only one spaces.
第七章 图
第七章 图测验
1、在一个无向图中,所有顶点的度数之和等于所有边数的( )倍。 In a undirected graph, the sum of degrees of all vertices is equal to the amount of all edges times (). A、2 B、3 C、1 D、1/2
2、在有向图G的拓扑序列中,若顶点在顶点之前,则下列情形不可能出现的是( )。 In the topological order sequences of the directed graph G, if vertex Vi appears before Vj, then the impossible situation of the following is () A、G中有一条从到的路径 There is a path from Vj to Vi in the G. B、G中有边(,) G contains edge (Vi,Vj). C、G中有一条从到的路径 G contains a path from Vi to Vj. D、G中没有边(,) G doesn't contain edge(Vi,Vj)
3、当各边上的权值满足什么要求时,宽度优先搜索算法可用来解决单源最短路径问题? What requirement do the weight of edges should satisfied to make width-first search algorithm can solve single source shortest path problem? A、均互不相等 Each edge is not equal to each other. B、均相等Equal C、不一定相等 No limitation. D、不一定相等(忽略该选项)
4、下面关于图的说法正确的有 The right statements of graphs in the following are: A、对于有向图,每个结点的出度必须要等于入度。As for directed graph, each vertices’ out-degree is equal to its in-degree. B、对于一个连通图,一定存在一种给边添加方向的方案使得这个图变成强连通图。For a connected graph, there must be a way of directing all the edges of the original graph to make the graph strongly connected graph. C、对于有向图,所有结点的入度加起来一定为奇数。For directed graph, the sum of in-degrees of all nodes must be odd number. D、对于无向图,所有结点的度数加起来一定是偶数。As for undirected graphs, the sum of degrees of all vertices is definitely even number. E、将有向图的一个强连通分量中的边全部反向仍然是强连通分量。Reversion all the edges of a strongly connected component of a directed graph, then the subgraph is still a strongly connected component.
5、下列关于最短路算法的说法正确的有: The right statements of the following are: A、当图中不存在负权回路但是存在负权边时,Dijkstra算法不一定能求出源点到所有点的最短路。 When the graph doesn't contain circuit of negative weight, but contains the edge of negative weight. Dijkstra algorithm can't guarantee the correctness of the algorithm. B、当图中不存在负权边时,Dijkstra算法能求出每对顶点间最短路径。 When the graph doesn't contain edge of negative weight, Dijkstra algorithm can calculate the shortest path of each pair of vertices. C、当图中存在负权回路时,Dijkstra算法也一定能求出源点到所有点的最短路。When the graph contains the circuit of negative weight, Dijkstra algorithm can certainly calculate the shortest path form the single source to all the vertices. D、Dijkstra算法不能用于每对顶点间最短路计算。Dijkstra algorithm can't be applied to calculate the shortest path of each pair of vertices.
6、下图中的强连通分量的个数为多少个? How many strongly connected graphs in the under graph?
7、如果无向图G=(V,E)是简单图,并且|V|=n>0,那么图G最多包含多少条边? If undirected graph G = (V,E) is simple graph, and |V| = n > 0, then how many edges can graph G contains at most?(There is only one correct answer)
8、有向图G如下图所示,请写出所有拓扑排序序列。所有的顶点都直接用其数字标号表示,如拓扑排序序列为,那么请写成1234(中间没有空格)。不同的拓扑排序序列按照字典序排序,中间用一个空格隔开。 Directed graph G looks like following graph, please list all the topological order sequences. All the vertices are marked by numbers directly. Like topological order sequence V1V2V3V4, we write it as 1234(with no blank space).Different topological order sequences are sorted according to alphabet order, and separated by a blank space.
9、无向图G=(V, E),其中:V={a, b, c, d, e, f}, E={(a, b), (a, e), (a, c), (b, e), (c, f), (f, d), (e, d)},对该图进行深度优先遍历(优先访问编号小的结点),得到的顶点序列为? 注意:答案中没有空格 Undirected G = (V,E), concretely: V = {a,b,c,d,e,f}, E = {(a,b),(a,e),(a,c),(b,e),(c,f),(f,d),(e,d)},perform depth-first traversal(visit the vertex of small number firstly), what vertices sequence do we get? Notice: no blank space in answer.
10、请使用Kruskal算法求出下图的最小生成树,依次写出每次被选择的合法的合并代价最小的边的编号(如果同时存在多条边满足要求,选择编号最小的)。顶点a到顶点b (a < b)之间的边编号为ab,例如图中权值为1的边编号为02。(不同编号之间用一个空格分隔) Please use Kruskal algorithm to the following graph and find the minimum spanning tree, and write the number of the valid vertex with minimum merging cost in turn(if there are many vertices satisfy requirement, choose the vertex with minimum number ). The number of the edge connecting vertex a and vertex b is ab. Like the edge with weight 1 in the graph, its number is 02(different numbers separated by a blank space).
11、请使用Prim算法从结点0出发求下图的最小生成树,依次写出每次被加入到最小生成树中边的编号(如果同时存在多条边满足要求,选择编号最小的)。顶点a到顶点b (a < b)之间的边编号为ab,例如图中权值为1的边编号为02。(不同编号之间用一个空格分隔) Please use prim algorithm starting from vertex 0 to find the minimum spanning tree of the following graph, write the number of the edge added into the minimum spanning tree in turn((if there are many vertices satisfy requirement, choose the vertex with minimum number). The number of the edge connecting vertex a and vertex b is ab. Like the edge with weight 1 in the graph, its number is 02(different numbers separated by a blank space).