数据结构英文试题

合集下载

数据结构 英文试题

数据结构 英文试题

以下是一份关于数据结构的英文试题,供您参考:1. What is the difference between an array and a linked list?Answer: An array and a linked list are two fundamental data structures used in computer science. An array is a linear data structure that stores elements in a consecutive memory location. It has a fixed size and the elements are accessed by their indices. On the other hand, a linked list is a dynamic data structure that consists of a set of nodes where each node contains the data and a reference (pointer) to the next node. The size of a linked list can vary dynamically and the elements are accessed in the order of their appearance.2. Explain the operation of binary search tree.Answer: A binary search tree is a tree-like data structure in which each node has at most two children, usually referred to as the left child and the right child. The value of each node in the binary search tree is greater than or equal to the value of all nodes in its left subtree and less than or equal to the value of all nodes in its right subtree. This property allows for efficient search, insertion, and deletion operations in the binary search tree. The search operation starts from the root node and compares the value with the target value, following the appropriate branch based on the comparison result until the target value is found or the appropriate action is taken. Insertion and deletion operations also involve maintaining the binary search tree property by adjusting the tree accordingly.3. What is the difference between a stack and a queue?Answer: A stack and a queue are two fundamental data structures used in computer science. A stack is a linear data structure that follows the Last In First Out (LIFO) principle. It allows the addition and removal of elements only at one end, usually referred to as the top of the stack. Elements are added to or removed from the stack using the push and pop operations, respectively. On the other hand, a queue is a linear data structure that follows the First In First Out (FIFO) principle. It allows the addition of elements at one end (rear) and removal of elements at the other end (front). Elements are added to or removed from the queue using the enqueue and dequeue operations, respectively.。

英文版数据结构算法题

英文版数据结构算法题

1.Suppose we have a linked list.Eack node has three parts: one data field and twolinked fields.The list has been linked by the first linked field link1,but the list is disorder.Try your best to sort the list with the second linked field into an increasing list.算法:int creasort(struct node &head){if (head.link1 == NULL) //没有结点return ERROR;head.link2 = head.link1; //设排列链表的第一个结点head.link2->link2 = NULL;p = head.link1->link1; //p为链表的第二个结点q = head; //q代表p插入位置的前一个结点if (!p) //只有一个结点return OK;while (p){while ( q->link2 && (q->link2->data < p->data)) //找查找入位置q = q->link2;if (!q->link2) //插在最后{q->link2 = p;}else //插在队列中间{p->link2 = q->link2;q->link2 = p;}p = p->link1;q = head;}return OK;}2.Suppose we have a sequence with the terminal character @.The format of thesequence can be S1&S2,S1 and S2 do not contain ‘&’, S2 is the reverse sequence of S1.Try to write an algorithm to check the sequence if the format of the sequence obeys the above fules then the function return TRUE otherwise FALSE.算法://s为待检查的字符串int checkrules(char *s){len = strlen(s);//用string.h自带函数取字符串s的长度if (len % 2 == 0) //字符串是偶数return FALSE;i = 0; //i指向字符串第一个字符n = len - 1;//n指向字符串最后一个字符while (i < len / 2 && ( s[i] != '&' || s[n] != '&')) //对半劈{if (s[i] == s[n]){i++;n--;}elsebreak;}if (i == len / 2 && s[i] == '&') //i指向中间元素且必须是’&’return TRUE;elsereturn FALSE;}3.Suppose we have a double-linked ciroular list L.Eack node has four fields:twolinked fiels pre and next, one data field data and one frequency field freq.At the beginning the initial value of freq is 0 and after each opeation Locate(L,x),the value in frequency field of x plus 1,and then sort the list according to freq into a non-increasing list.The node which is most frequently accessed is the first node after the head node.算法:void Locate(struct doulin L, int x){struct doulin *; //访问时用到的遍历指针if (x > L.data) //无效的访问return;p = &L; //定位,p指向已经访问的指针while(x--){p = p->next;}p->freq++;//因为形参L不在循环链表里,因此要用L.pre->next表示循环链表的头结点while (p->pre ->freq < p->freq && p->pre != L.pre->next){p->data <-> p->pre->data;p->freq <-> p->pre->freq;}}4.Suppose we have a disordered list of integers.The list has been stored in a stack.You are supposed to sort the list with queue.算法://表示将from队的元素倒到to中void QueToQue(Queue *from, Queue *to, int ns){ tag = 0; //用于标注要排列的数是否进栈while (!QueueEmpty(from)){ DeQueue(from, &nq); //nq用于存取出队元素if ((tag == 0 && nq > ns) || tag == 1) //不能入队EnQueue(to, nq);else //可以入队了{ tag = 1; //设置标志tag为1,表示已经入队了EnQueue(to, ns);EnQueue(to, nq);}}if (tag == 0) //当ns比队中任何数都大时EnQueue(to, ns);}//将队列from中的元素倒到to栈中void QueToStack(Queue *from, Stack *to){ while (!QueueEmpty(from)){ DeQueue(from, &nq);Push(to, nq);}}//排序的本体void sort(Stack *S){ InitQueue(&Q1); InitQueue(&Q2); //初始化两个队列Q1,Q2Pop(S, &ns); EnQueue(&Q1, ns); //先将一个元素出队进栈while (!StackEmpty(S)){ Pop(S,&ns);if (!QueueEmpty(&Q1)) //若Q1队列不空(即Q2队列为空)QueToQue(&Q1, &Q2, ns);else //若Q2队列为空(即Q1队列不为空)QueToQue(&Q2, &Q1, ns);}if (!QueueEmpty(&Q1)) //Q1不为空,也就是要把Q1队载入栈QueToStack(&Q1, S);elseQueToStack(&Q2, S);}5.颜色排列的算法://colors是颜色数组,number是数组大小void colorsort(int *colors, int number){i = 0, j = number – 1;while (colors[i] == 1) //找到第一个非1的单元i++;while (colors[j] == 3) //找到最后一个非3的单元j--;k = i; //遍历指针设为iwhile(k <= j){switch (colors[k]){case 1: colors[k]<->colors[i];i++; k++;break;case 2: k++;break;case 3: colors[k]<->colors[j];j--;break;}}}。

数据结构英文试卷A及谜底NEW

数据结构英文试卷A及谜底NEW

数据结构英⽂试卷A及谜底NEWFinal examination2009 FallData Structure and Algorithm DesignClass:Student Number:Name:TeacherNo.123456789TotalMark1.Single-Choice(20 points)(1) Consider the following definition of a recursive function ff. int ff( int n ) { if( n == 0 ) return 1; return 2 * ff( n - 1 ); }If n > 0, what is returned by ff( n )? (a) log 2 n (b) n 2 (c) 2n (d) 2 * n(2) An input into a stack is like 1,2,3,4,5,6. Which output is impossible? .a. 2,4,3,5,1,6b.3,2,5,6,4,1c.1,5,4,6,2,3d.4,5,3,6,2,1(3) Which of the following data structures uses a "Last-in, First-out" policy for element insertionand removal? (a) Stack (b) Tree (c) Hash table (d) Queue (4) If deleting the i th key from a contiguous list with n keys, keys need to be shifted leftone position.a. n-i b. n-i+1 c. i d. n-i-1(5) Sorting a key sequence (28,84,24,47,18,30,71,35,23), its status is changed as follows.23,18,24,28,47,30,71,35,8418,23,24,28,35,30,47,71,8418,23,24,28,30,35,47,71,84The sorting method is called (a).select sorting (b).Shell sorting (c).merge sorting (d).quick sorting(6) The number of keyword in every node except root in a B- tree of order 5 is _ _ at least管路术中要进⾏检查和检测处理。

数据结构英文试题

数据结构英文试题

杭州电子工业学院学生考试卷(A)卷1.(8分) Imagine we have two empty stacks of integers, s1 and s2. draw a picture of each stack after the following operations:PushStack (s1, 3);PushStack (s1, -5);PushStack (s1, 7);PushStack (s1, -9);PushStack (s1, 11);PushStack (s1, -13);while (not emptyStack (s1)) {popStack (s1, x);if (x < 0) {pushStack (s2, x);}} //while2. (8分)Using manual transformation, change the following postfix or prefix expressions to infix form.a. ABC+*D-b. -*A+BCD3. (8分) what would be the contents of queue Q1 after the following code is executed and the following data are entered?Q1 = CreateQueueS1 = CreateStackloop (not end of file)read numberif (number not 0)pushStack (S1, number)elsepopStack (S1, x)popStack (S1, x)loop (not emptyStack (S1))popStack (S1, x)enqueue (Q1, x)end loopend ifend loopThe data are 5, 7, 12, 4, 0, 4, 6, 8, 67, 34, 23 , 5, 0, 44, 33, 22, 6, 0.4. (8分) Create a AVL tree using the following data entered as a sequential set :7, 10, 14, 23, 33, 56, 66, 70, 80, 90.5. (8分)Show the resulting heap after 33, 22, and 8 are added to the following heap :50, 30, 40, 20, 10, 25, 35, 10, 5.6. (8分) After two passes of a sorting algorithm, the follow array :48, 5, 29, 36, 7, 61, 88has been rearranged as shown below :5, 7, 48, 29, 36, 61, 88which sorting algorithm is being used (straight selection, bubble, straight insertion) ? Defend your answer.7.(8分)A graph can be used to show relationships, for example, from the following list of people belonging to the same club (vertices) and their friendships (edges). People = {George, Jim, Jean, Frank, Fred, John, Susan} FriendShip = {(George, Jean), (Frank, Fred), (George, John), (Jim, Fred), (Jim, Frank),(Jim, Susan), (Susan, Frank) }Give the adjacency list representation of this graph.Algorithm Design1.(11分)Write an algorithm that traverses a linked list and deletes all nodes whose keys are negative.2.(11分)Write an algorithm that counts the number of leaves in a binary tree.3.(11分)Write an algorithm called QueueToStack that creates a stack from a queue. At the end of the algorithm, the queue should be unchanged; the front of the queue should be the top of the stack; and the rear of the queue should be the base of the stack.4. (11分) Develop a non-recursive BST (Binary Search Tree) search algorithm SearchBST.。

数据结构期末试卷B3860.doc

数据结构期末试卷B3860.doc

数据结构期末试卷B3860A book, like a ship, leads us from a narrow place to an infinite sea of life, CalebData structure final paper B1, judge: 10 points, 1 point per question.A full binary tree is also a complete binary treeThe binary tree can be represented by an ordered tree of 0 or less than or equal to 2(a)In the k cross tree where there is only a degree of zero and a degree of k, there are nO of the nodes of 0, and nk for the nodes of k, and nO 二nk + 14,the shortest path to another vertex in a graph with the right connection is not necessarily the only oneIn the undirected graph of n nodes, if the number of edges is less than n minus 1, the graph must be an unconnected graph The binary tree with the shortest path length of the tree must have no node of 1The lookup of the hash table does not need to be compared to the keywordThe binary search method can be used to search for linear linked lists ordered by valueIterating over a heap does not necessarily get an ordered sequenceBecause the last trip of hill sort is the same as the direct insertion sort process, the former must spend more time than the latter2, fill in the blanks: (20 points, 2 points each.)A node with a degree of zero degrees is a node with no subtreesThe son of the same node is called a ____________In a binary linked list with n nodes, there is an empty chainThe adjacency matrix is used for the adjacency matrix storage method, and the adjacency matrix must be a4, a given sequence {100, 86, 4& 73, 35, 39, 42, 57, 66, 21}, as defined by the heap structure, it is an _____________________ heapIn the case of direct insertion sort, the number of data is compared with the initial order of data. In the case of direct selection, the number of data compared with the data is inThe function H, which converts the node keyword to the location of the node, is called __________________ or ____________The sequence of n key words is sorted rapidly, and the space complexity of the average case isChoice: 20 points, 2 points per problem・1, will be a totally has 100 node in the binary tree from top to bottom, from left to right in turn on node number, the serial number of the root node is 1, the number of node,s left child for 49 Numbers forA. 98 b. 99C. 50 d. 48The shape of the heap is aA. AC. complete binary tree d. balance binary treeFor the hash function H (key)二key MOD 13, the keyword that is called a synonym isA. 35 and 41 b. 23 and 39C. 15 and 44 d. 25 and 51Point out how many comparisons are required to find 12 in order tables {2, 5, 5, 7, 10, 14, 15, 1& 23, 35, 41, 52}A, 2, B, 3C, 4, D, 5Suppose a graph with an n vertex and an arc of e is indicatedby the adjacency list, and the time complexity associated with a vertex vi is removed: ___________________A. 0 (n) b. o. (e)C. 0 (n + e)D. 0 (n * e)When looking for dn element in a binary sort tree, its time complexity is approximatelyA, 0 (n) B, 0 (1)C, 0 (log2n) D, 0 (n2)The weight of a tree that has a weight of 3, 8, 6, 2, 5 leaves a Huffman tree with a right path length ofA, 24, B, 48C, 72, D, 53& A character sequence {Q, H, C, Y, P, A, M, S, D, F, R, X}, A trip to the sorting result for {F, H, C, D, P, A, M, Q, R,S, Y, X}, is which of the following sorting algorithmsA, blisters sort B, and the initial step is A sequence of 4 shellsC, 2 merge sort D, and the first element is the quicksort of the boundary elementA tree that is not connected to a connected graph is a.・・that contains all the vertices of the connected graphA: very little connected subgraph BC. greatly connected subgraphD. Large subgraphThe width of the diagram is first traversed by a type similar to the binary treeA. first order traversal B・ Sequence traversalThe post-order traversal of the DFour, answer the question: (total 28 minutes, each question 4)1,the binary tree that is shown in the picture is completed in order traversal, the following sequence traversal, the first sequence traversing, and drawing the binary tree of the middle sequence clues2,please give the adjacency matrix and the adjacency list below, and write the vertex sequence that is the highest priority and breadth of the graph from vertex aFor the diagram below, draw the minimum spanning treeA table 4, known as (49, 66, 73, 52, 40, 37, 65, 43), made according to the order of the elements in the table, in turn, insert a initial empty binary sort tree, draw the binary sort tree elements in the tableA three-order b~tree is shown below, assuming that the key words are removed in sequence, 46, 24, 815, and you can draw the tree after each delete node:6,known as a group of keywords, 14, 23, 01, 68, 20, 84, 27, 55, 11, 10, 79 (19), then the hash function H (key)二key MOD and linear detection method of conflict resolution structure of this group of 13 key hash tableDo you know if the following sequence is a heap? If not, adjust it to heap:(5, 56, 20, 234, 38,29,61,35, 76,28, 100)Program (22 points)Read the following algorithm and answer the following questions: (4)Perfect the program, and answer what the algorithm does? What is the function of r [n + 1] in the algorithm?Void sort (elemtype r [], int n)(int k, I;For (k = n minus 1; k > 二1; k -)・If (r [k] > r [k + 1]){r [n + 1]二r [k];,,For,z (I 二k + 1; r [I] < r [n + 1] ; I + +)R [I - 1] = r [I}}Complete the following program and say what the algorithm does(8)Void weizhisort (struct node r [n], int n)(int low, high, mid, j, I;For (I 二2; I 〈二n; I++){r[0]二r [I];Low 二________ ;High 二...Wh订e (low < = high)Well, it's going to be (1 ow + high) / 2; If (r[0]. Key < r [mid]. Key)Else low 二mid + 1; }For (j 二I - 1).R [j + 1]二T [j];R [high + 1] = r [0];}The data type is defined as:Struct node(int key:Infotypes otherinfo;3, say what the algorithm does(2 points)Void delete (int a [n], int I){if (I < 0) > =n) printf (〃error 〃);The else (j 二i-1; j 〈n; j + +)A [j]二 a [j + 1];N is equal to n minus 1; } }Improve the program to show its function (8 points)# define NULL 0;Typedef struct Bitnode {Char data;Struct Bitnode * lchild・} Bitreptr;Void inorder_notrecursive (Bitreptr bt, Status (TelemType e)) {InitStack (S):P 二T;While (P | |! StackEmpty (s)){if (P) {Push (S, P);;The else {If (! (p-> data)) return Error;} return OK;A book, like a ship, leads us from a narrow place to an infinite sea of life, caleb。

JAVA数据结构习题及解答(英)

JAVA数据结构习题及解答(英)

QuestionsThese questions are intended as a self-test for readers.Answers to the questions may be found in Appendix C.1.In many data structures you can________a single record,_________it,and_______it.2.Rearranging the contents of a data structure into a certain order is called_________.30CHAPTER1Overview3.In a database,a field isa.a specific data item.b.a specific object.c.part of a record.d.part of an algorithm.4.The field used when searching for a particular record is the______________.5.In object-oriented programming,an objecta.is a class.b.may contain data and methods.c.is a program.d.may contain classes.6.A classa.is a blueprint for many objects.b.represents a specific real-world object.c.will hold specific values in its fields.d.specifies the type of a method.7.In Java,a class specificationa.creates objects.b.requires the keyword new.c.creates references.d.none of the above.8.When an object wants to do something,it uses a________.9.In Java,accessing an object’s methods requires the_____operator.10.In Java,boolean and byte are_____________.(There are no experiments or programming projects for Chapter1.)Questions31Chapter1,OverviewAnswers to Questions1.insert,search for,delete2.sorting3.c4.search key5.b6.a7.d8.method9.dot10.data typesQuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.1.Inserting an item into an unordered arraya.takes time proportional to the size of the array.b.requires multiple comparisons.c.requires shifting other items to make room.d.takes the same time no matter how many items there are.2.True or False:When you delete an item from an unordered array,in most cases you shift other items to fill in the gap.3.In an unordered array,allowing duplicatesa.increases times for all operations.b.increases search times in some situations.c.always increases insertion times.d.sometimes decreases insertion times.4.True or False:In an unordered array,it’s generally faster to find out an item is not in the array than to find out it is.5.Creating an array in Java requires using the keyword________.6.If class A is going to use class B for something,thena.class A’s methods should be easy to understand.b.it’s preferable if class B communicates with the program’s user.c.the more complex operations should be placed in class A.d.the more work that class B can do,the better.7.When class A is using class B for something,the methods and fields class A can access in class B are called class B’s__________.74CHAPTER2Arrays8.Ordered arrays,compared with unordered arrays,area.much quicker at deletion.b.quicker at insertion.c.quicker to create.d.quicker at searching.9.A logarithm is the inverse of_____________.10.The base10logarithm of1,000is_____.11.The maximum number of elements that must be examined to complete a binary search in an array of200elements isa.200.b.8.c.1.d.13.12.The base2logarithm of64is______.13.True or False:The base2logarithm of100is2.14.Big O notation tellsa.how the speed of an algorithm relates to the number of items.b.the running time of an algorithm for a given size data structure.c.the running time of an algorithm for a given number of items.d.how the size of a data structure relates to the number of items.15.O(1)means a process operates in_________time.16.Either variables of primitive types or_________can be placed in an array. Chapter2,ArraysAnswers to Questions1.d2.True3.b4.False5.new6.d740APPENDIX C Answers to Questions7.interface8.d9.raising to a power10.311.812.613.False14.a15.constant16.objectsuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.puter sorting algorithms are more limited than humans in thata.humans are better at inventing new algorithms.puters can handle only a fixed amount of data.c.humans know what to sort,whereas computers need to be told.puters can compare only two things at a time.2.The two basic operations in simple sorting are_________items and_________ them(or sometimes_________them).3.True or False:The bubble sort always ends up comparing every item with every other item.4.The bubble sort algorithm alternates betweenparing and swapping.b.moving and copying.c.moving and comparing.d.copying and comparing.5.True or False:If there are N items,the bubble sort makes exactly N*N comparisons.Questions1096.In the selection sort,a.the largest keys accumulate on the left(low indices).b.a minimum key is repeatedly discovered.c.a number of items must be shifted to insert each item in its correctlysorted position.d.the sorted items accumulate on the right.7.True or False:If,in a particular sorting situation,swaps take much longer than comparisons,the selection sort is about twice as fast as the bubble sort.8.A copy is________times as fast as a swap.9.What is the invariant in the selection sort?10.In the insertion sort,the“marked player”described in the text corresponds to which variable in the insertSort.java program?a.inb.outc.tempd.a[out]11.In the insertion sort,“partially sorted”means thata.some items are already sorted,but they may need to be moved.b.most items are in their final sorted positions,but a few still need to be sorted.c.only some of the items are sorted.d.group items are sorted among themselves,but items outside the groupmay need to be inserted in it.12.Shifting a group of items left or right requires repeated__________.13.In the insertion sort,after an item is inserted in the partially sorted group,it willa.never be moved again.b.never be shifted to the left.c.often be moved out of this group.d.find that its group is steadily shrinking.110CHAPTER3Simple Sorting14.The invariant in the insertion sort is that________.15.Stability might refer toa.items with secondary keys being excluded from a sort.b.keeping cities sorted by increasing population within each state,in a sortby state.c.keeping the same first names matched with the same last names.d.items keeping the same order of primary keys without regard to secondary keys.Chapter3,Simple SortingAnswers to Questions1.dparing and swapping(or copying)3.False4.a5.False6.b7.False8.three9.Items with indices less than or equal to outer are sorted.10.c11.d12.copies13.b14.Items with indices less than outer are partially sorted.15.buestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.1.Suppose you push10,20,30,and40onto the stack.Then you pop three items. Which one is left on the stack?2.Which of the following is true?a.The pop operation on a stack is considerably simpler than the remove operation on a queue.b.The contents of a queue can wrap around,while those of a stack cannot.c.The top of a stack corresponds to the front of a queue.d.In both the stack and the queue,items removed in sequence are takenfrom increasingly high index cells in the array.3.What do LIFO and FIFO mean?4.True or False:A stack or a queue often serves as the underlying mechanism on which an ADT array is based.5.Assume an array is numbered with index0on the left.A queue representing a line of movie-goers,with the first to arrive numbered1,has the ticket window on the right.Thena.there is no numerical correspondence between the index numbers andthe movie-goer numbers.b.the array index numbers and the movie-goer numbers increase inopposite left-right directions.c.the array index numbers correspond numerically to the locations in theline of movie-goers.d.the movie-goers and the items in the array move in the same direction.6.As other items are inserted and removed,does a particular item in a queue move along the array from lower to higher indices,or higher to lower?7.Suppose you insert15,25,35,and45into a queue.Then you remove three items.Which one is left?8.True or False:Pushing and popping items on a stack and inserting and removing items in a queue all take O(N)time.174CHAPTER4Stacks and Queues9.A queue might be used to holda.the items to be sorted in an insertion sort.b.reports of a variety of imminent attacks on the star ship Enterprise.c.keystrokes made by a computer user writing a letter.d.symbols in an algebraic expression being evaluated.10.Inserting an item into a typical priority queue takes what big O time?11.The term priority in a priority queue means thata.the highest priority items are inserted first.b.the programmer must prioritize access to the underlying array.c.the underlying array is sorted by the priority of the items.d.the lowest priority items are deleted first.12.True or False:At least one of the methods in the priorityQ.java program (Listing4.6)uses a linear search.13.One difference between a priority queue and an ordered array is thata.the lowest-priority item cannot be extracted easily from the array as it can from the priority queue.b.the array must be ordered while the priority queue need not be.c.the highest priority item can be extracted easily from the priority queue but not from the array.d.All of the above.14.Suppose you based a priority queue class on the OrdArray class in the orderedArray.java program(Listing2.4)in Chapter2,“Arrays.”This will buy you binary search capability.If you wanted the best performance for your priority queue,would you need to modify the OrdArray class?15.A priority queue might be used to holda.passengers to be picked up by a taxi from different parts of the city.b.keystrokes made at a computer keyboard.c.squares on a chessboard in a game program.d.planets in a solar system simulation.Chapter4,Stacks and QueuesAnswers to Questions1.102.bst-In-First-Out;and First-In-First-Out4.False.It’s the other way around.5.b6.It doesn’t move at all.7.458.False.They take O(1)time.9.c10.O(N)11.c12.True13.b14.Yes,you would need a method to find the minimum value.15.aQuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.Questions2451.Which of the following is not true?A reference to a class objecta.can be used to access public methods in the object.b.has a size dependant on its class.c.has the data type of the class.d.does not hold the object itself.2.Access to the links in a linked list is usually through the_________link.3.When you create a reference to a link in a linked list,ita.must refer to the first link.b.must refer to the link pointed to by current.c.must refer to the link pointed to by next.d.can refer to any link you want.4.How many references must you change to insert a link in the middle of a singly linked list?5.How many references must you change to insert a link at the end of a singly linked list?6.In the insertFirst()method in the linkList.java program(Listing5.1),the statement newLink.next=first;means thata.the next new link to be inserted will refer to first.b.first will refer to the new link.c.the next field of the new link will refer to the old first link.d.newLink.next will refer to the new first link in the list.7.Assuming current points to the next-to-last link in a singly linked list,what statement will delete the last link from the list?8.When all references to a link are changed to refer to something else,what happens to the link?9.A double-ended lista.can be accessed from either end.b.is a different name for a doubly linked list.c.has pointers running both forward and backward between links.d.has its first link connected to its last link.246CHAPTER5Linked Lists10.A special case often occurs for insertion and deletion routines when a list is ________.11.Assuming a copy takes longer than a comparison,is it faster to delete an item with a certain key from a linked list or from an unsorted array?12.How many times would you need to traverse a singly linked list to delete the item with the largest key?13.Of the lists discussed in this chapter,which one would be best for implementing a queue?14.Which of the following is not true?Iterators would be useful if you wanted toa.do an insertion sort on a linked list.b.insert a new link at the beginning of a list.c.swap two links at arbitrary locations.d.delete all links with a certain key value.15.Which do you think would be a better choice to implement a stack:a singly linked list or an array?Chapter5,Linked ListsAnswers to Questions1.b2.first3.d4.25.16.c7.current.next=null;8.Java’s garbage collection process destroys it.Chapter5,Linked Lists7419.a10.empty11.a linked list12.once,if the links include a previous reference13.a double-ended list14.bually,the list.They both do push()and pop()in O(1)time,but the list uses memory more efficiently.QuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.1.If the user enters10in the triangle.java program(Listing6.1),what is the maximum number of“copies”of the triangle()method(actually just copies of its argument)that exist at any one time?2.Where are the copies of the argument,mentioned in question1,stored?a.in a variable in the triangle()methodb.in a field of the TriangleApp classc.in a variable of the getString()methodd.on a stack3.Assume the user enters10as in question1.What is the value of n when the triangle()method first returns a value other than1?4.Assume the same situation as in question1.What is the value of n when the triangle()method is about to return to main()?5.True or false:In the triangle()method,the return values are stored on thestack.6.In the anagram.java program(Listing6.2),at a certain depth of recursion,a version of the doAnagram()method is working with the string“led”.When this method calls a new version of itself,what letters will the new version be working with?7.We’ve seen that recursion can take the place of a loop,as in the loop-oriented orderedArray.java program(Listing2.4)and the recursive binarySearch.java program(Listing6.3).Which of the following is not true?a.Both programs divide the range repeatedly in half.b.If the key is not found,the loop version returns because the rangebounds cross,but the recursive version occurs because it reaches thebottom recursion level.c.If the key is found,the loop version returns from the entire method, whereas the recursive version returns from only one level of recursion.d.In the recursive version the range to be searched must be specified in the arguments,while in the loop version it need not be.310CHAPTER6Recursion8.In the recFind()method in the binarySearch.java program(Listing6.3),what takes the place of the loop in the non-recursive version?a.the recFind()methodb.arguments to recFind()c.recursive calls to recFind()d.the call from main()to recFind()9.The binarySearch.java program is an example of the_________approach to solving a problem.10.What gets smaller as you make repeated recursive calls in the redFind() method?11.What becomes smaller with repeated recursive calls in the towers.java program (Listing6.4)?12.The algorithm in the towers.java program involvesa.“trees”that are data storage devices.b.secretly putting small disks under large disks.c.changing which columns are the source and destination.d.moving one small disk and then a stack of larger disks.13.Which is not true about the merge()method in the merge.java program(Listing6.5)?a.Its algorithm can handle arrays of different sizes.b.It must search the target array to find where to put the next item.c.It is not recursive.d.It continuously takes the smallest item irrespective of what array it’s in.14.The disadvantage of mergesort is thata.it is not recursive.b.it uses more memory.c.although faster than the insertion sort,it is much slower than quicksort.d.it is complicated to implement.15.Besides a loop,a___________can often be used instead of recursion. Chapter6,RecursionAnswers to Questions1.102.d3.24.105.false6.“ed”7.b8.c9.divide-and-conquer10.the range of cells to search11.the number of disks to transfer12.c13.b14.b15.stackQuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.1.The Shellsort works bya.partitioning the array.b.swapping adjacent elements.c.dealing with widely separated elements.d.starting with the normal insertion sort.2.If an array has100elements,then Knuth’s algorithm would start with an interval of________.Questions3613.To transform the insertion sort into the Shellsort,which of the following do you not do?a.Substitute h for1.b.Insert an algorithm for creating gaps of decreasing width.c.Enclose the normal insertion sort in a loop.d.Change the direction of the indices in the inner loop.4.True or false:A good interval sequence for the Shellsort is created by repeatedly dividing the array size in half.5.Fill in the big O values:The speed of the Shellsort is more than_______but less than________.6.Partitioning isa.putting all elements larger than a certain value on one end of the array.b.dividing an array in half.c.partially sorting parts of an array.d.sorting each half of an array separately.7.When partitioning,each array element is compared to the_______.8.In partitioning,if an array element is equal to the answer to question7,a.it is passed over.b.it is passed over or not,depending on the other array element.c.it is placed in the pivot position.d.it is swapped.9.True or false:In quicksort,the pivot can be an arbitrary element of the array.10.Assuming larger keys on the right,the partition isa.the element between the left and right subarrays.b.the key value of the element between the left and right subarrays.c.the left element in the right subarray.d.the key value of the left element in the right subarray.11.Quicksort involves partitioning the original array and then_________.362CHAPTER7Advanced Sorting12.After a partition in a simple version of quicksort,the pivot may beed to find the median of the array.b.exchanged with an element of the right subarray.ed as the starting point of the next partition.d.discarded.13.Median-of-three partitioning is a way of choosing the_______.14.In quicksort,for an array of N elements,the partitionIt()method will examine each element approximately______times.15.True or false:You can speed up quicksort if you stop partitioning when the partition size is5and finish by using a different sort.Chapter7,Advanced SortingAnswers to Questions1.c2.403.d4.false5.O(N*logN),O(N2)6.a7.pivot8.d9.true10.c11.partitioning the resulting subarrays12.b13.pivot14.log2N15.trueQuestionsThese questions are intended as a self-test for readers.Answers may be found inAppendix C.1.Insertion and deletion in a tree require what big O time?2.A binary tree is a search tree ifa.every non-leaf node has children whose key values are less than(or equalto)the parent.b.every left child has a key less than the parent and every right child has akey greater than(or equal to)the parent.c.in the path from the root to every leaf node,the key of each node isgreater than(or equal to)the key of its parent.d.a node can have a maximum of two children.3.True or False:Not all trees are binary trees.4.In a complete binary tree with20nodes,and the root considered to be at level 0,how many nodes are there at level4?5.A subtree of a binary tree always hasa.a root that is a child of the main tree’s root.b.a root unconnected to the main tree’s root.c.fewer nodes than the main tree.d.a sibling with the same number of nodes.6.In the Java code for a tree,the______and the_______are generally separate classes.Questions4237.Finding a node in a binary search tree involves going from node to node, askinga.how big the node’s key is in relation to the search key.b.how big the node’s key is compared to its right or left children.c.what leaf node we want to reach.d.what level we are on.8.An unbalanced tree is onea.in which most of the keys have values greater than the average.b.whose behavior is unpredictable.c.in which the root or some other node has many more left children thanright children,or vice versa.d.that is shaped like an umbrella.9.Inserting a node starts with the same steps as_______a node.10.Suppose a node A has a successor node S.Then S must have a key that is larger than_____but smaller than or equal to_______.11.In a binary tree used to represent a mathematical expression,which of the following is not true?a.Both children of an operator node must be operands.b.Following a postorder traversal,no parentheses need to be added.c.Following an inorder traversal,parentheses must be added.d.In pre-order traversal a node is visited before either of its children.12.If a tree is represented by an array,the right child of a node at index n has an index of_______.13.True or False:Deleting a node with one child from a binary search tree involves finding that node’s successor.14.A Huffman tree is typically used to_______text.15.Which of the following is not true about a Huffman tree?a.The most frequently used characters always appear near the top of the tree.b.Normally,decoding a message involves repeatedly following a path fromthe root to a leaf.424CHAPTER8Binary Treesc.In coding a character you typically start at a leaf and work upward.d.The tree can be generated by removal and insertion operations on apriority queue.Chapter8,Binary TreesAnswers to Questions1.O(logN)2.b3.True4.55.c6.node,tree7.a8.cChapter8,Binary Trees7439.finding10.A,A’s left-child descendents11.d12.2*n+113.Falsepress15.cQuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.1.A2-3-4tree is so named because a node can havea.three children and four data items.b.two,three,or four children.c.two parents,three children,and four items.d.two parents,three items,and four children.2.A2-3-4tree is superior to a binary search tree in that it is________.3.Imagine a parent node with data items25,50,and75.If one of its child nodes had items with values60and70,it would be the child numbered__________.4.True or False:Data items are located exclusively in leaf nodes.514CHAPTER102-3-4Trees and External Storage5.Which of the following is not true each time a node is split?a.Exactly one new node is created.b.Exactly one new data item is added to the tree.c.One data item moves from the split node to its parent.d.One data item moves from the split node to its new sibling.6.A2-3-4tree increases its number of levels when________.7.Searching a2-3-4tree does not involvea.splitting nodes on the way down if necessary.b.picking the appropriate child to go to,based on data items in a node.c.ending up at a leaf node if the search key is not found.d.examining at least one data item in any node visited.8.After a non-root node of a2-3-4tree is split,does its new right child contain the item previously numbered0,1,or2?9.A4-node split in a2-3-4tree is equivalent to a_______in a red-black tree.10.Which of the following statements about a node-splitting operation in a2-3 tree(not a2-3-4tree)is not true?a.The parent of a split node must also be split if it is full.b.The smallest item in the node being split always stays in that node.c.When the parent is split,child2must always be disconnected from itsold parent and connected to the new parent.d.The splitting process starts at a leaf and works upward.11.What is the big O efficiency of a2-3tree?12.In accessing data on a disk drive,a.inserting data is slow but finding the place to write data is fast.b.moving data to make room for more data is fast because so many items can be accessed at once.c.deleting data is unusually fast.d.finding the place to write data is comparatively slow but a lot of data can be written quickly.13.In a B-tree each node contains_______data items.Questions51514.True or False:Node splits in a B-tree have similarities to node splits in a2-3 tree.15.In external storage,indexing means keeping a file ofa.keys and their corresponding blocks.b.records and their corresponding blocks.c.keys and their corresponding records.st names and their corresponding keys.Chapter9,Red-Black TreesAnswers to Questions1.in order(or inverse order)2.b3.False4.d5.b6.rotations,changing the colors of nodes7.red8.a9.left child,right child10.d11.a node,its two children12.b13.True14.a15.TrueQuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.574CHAPTER11Hash Tablesing big O notation,say how long it takes(ideally)to find an item in a hash table.2.A__________transforms a range of key values into a range of index values.3.Open addressing refers toa.keeping many of the cells in the array unoccupied.b.keeping an open mind about which address to use.c.probing at cell x+1,x+2,and so on until an empty cell is found.d.looking for another location in the array when the one you want is occupied.ing the next available position after an unsuccessful probe is called_____________.5.What are the first five step sizes in quadratic probing?6.Secondary clustering occurs becausea.many keys hash to the same location.b.the sequence of step lengths is always the same.c.too many items with the same key are inserted.d.the hash function is not perfect.7.Separate chaining involves the use of a_____________at each location.8.A reasonable load factor in separate chaining is________.9.True or False:A possible hash function for strings involves multiplying each character by an ever-increasing power.10.The best technique when the amount of data is not well known isa.linear probing.b.quadratic probing.c.double hashing.d.separate chaining.11.If digit folding is used in a hash function,the number of digits in each group should reflect_____________.12.True or False:In linear probing an unsuccessful search takes longer than a successful search.Questions57513.In separate chaining the time to insert a new itema.increases linearly with the load factor.b.is proportional to the number of items in the table.c.is proportional to the number of lists.d.is proportional to the percentage of full cells in the array.14.True or False:In external hashing,it’s important that the records don’t become full.15.In external hashing,all records with keys that hash to the same value are located in___________.Chapter11,Hash TablesAnswers to Questions1.O(1)2.hash function3.d4.linear probing5.1,4,9,16,256.b7.linked listChapter11,Hash Tables7458.1.09.True10.d11.the array size12.False13.a14.False15.the same blockQuestionsThese questions are intended as a self-test for readers.Answers may be found in Appendix C.1.What does the term complete mean when applied to binary trees?a.All the necessary data has been inserted.b.All the rows are filled with nodes,except possibly the bottom one.c.All existing nodes contain data.d.The node arrangement satisfies the heap condition.2.What does the term weakly ordered mean when applied to heaps?3.A node is always removed from the__________.4.To“trickle up”a node in a descending heap meansa.to repeatedly exchange it with its parent until it’s larger than its parent.b.to repeatedly exchange it with its child until it’s larger than its child.c.to repeatedly exchange it with its child until it’s smaller than its child.d.to repeatedly exchange it with its parent until it’s smaller than its parent.5.A heap can be represented by an array because a heap。

2012--数据结构英文试卷A及答案

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分)}}。

数据结构样卷2(英文)

数据结构样卷2(英文)

重庆大学 数据结构 课程样卷2开课学院: 计算机学院 课程号: 18001035 考试日期:考试方式:考试时间: 120 分钟一. Single choice1. The linear list (a1, a2, ... an), which is in Sequential Storage , whenwe delete any node, the average number of moving nodes ( ). A. n B. n/2 C. (n-1)/2 D. (n+1)/2 2. Which is wrong among the following statements ( ).A. Data element is the basic unit of the dataB. Data element is the smallest unit of the dataC. Data can be composed of a number of data elementsD. Data items can be composed of a number of data elements3. To insert a data element in a linear structure data conveniently, thebest data structure is ( ).A. Sequential storageB. Linked storageC.Index storageD. Hash storage4. If insert a new node into the doubly linked list which the number ofnodes is n, the measurement level of time complexity is ( ).A.O(1)B. O(n)C. O(nlog 2n)D. O(n 2)5. In virtue of a child’s Brother linked lists as a tree, if we want tofind the fifth child of the node x, as long as finding the first child of x, and then ( ).A. pointer scans 5 nodes continuously from the child domainB. pointer scans 4 nodes continously from the child domainC. pointer scans 5 nodes continously from the brother domainD. pointer scans 4 nodes continously from the brother domain 6. The character of Tree structure is: a node can have( )A. More than one direct pre-trendB. More than one direct successorsC. More than one pre-trendD. A successor7. Assume that there are 13 numbers, they form a Huffman tree, calculatethe number of nodes on this Huffman tree ( ). A. 13 B. 12 C. 26 D. 258. A spanning tree of the undirected connected graph is a ( ) whichcontains the whole vertices of this connected graph.A. Minimal connected subgraphB. Minimal subgraphC. Significantly connected sub-graphD. Significantly sub-graph 9. Which is wrong in the following statements ( ).A. Each vertex is only visited once during the graph traversal.B. There are two methods, Depth-First Search and Breadth-First Search,to traverse a graph.C. Depth-First Search of a graph isn ’t fit to a directed graphD. Depth-first search of a graph is a recursive process10. In sequential search algorithm of static table, if we set up a sentryat the head of a list, the right way to find the element is ( ) A. Looking for the data element from the first element to the back B. Looking for the data element from the second element to the back C. Looking for the data element from the (n+1)th element to the front D. I t is nothing to do with the search for order11. In order to find the number 85 in an ordered list(18,20,25,34,48,62,74,85), how many times do we need to compare( ) A.Once B. Twice C. 3 times D. 4 times12. Assume that the length of Hash table is m=14, Hash function H(key) =key % 11. There have been 4 nodes in the table, and their addresses are: 4,5,6,7. Other addresses are NULL. In virtue of quadratic probing re-hash to deal with conflict, calculate the address of node whose keyword is 9 ( ).A. 8B. 3C. 5D. 913. Using Quicksort to sort the following four sequences, and choose the命题人:组题人:审题人:命题时间:教务处制学院 专业、班 年级 学号 姓名公平竞争、诚实守信、严肃考纪、拒绝作弊封线密first element as the benchmark to divide. During the first division,in the following sequences which need to move the most times ( )A.70,75,82,90,23,16,10,68B.70,75,68,23,10,16,90,82C.82,75,70,16,10,90,68,23D.23,10,16,70,82,75,68,9014.There are 10000 elements in a sequence, the best way to get the very smallest 10 elements in the sequence is ( ).A. QuicksortB. HeapsortC. Insertion sortD. Merge sort15.If the sequence is almost in order, take compare times of key code and move times of key code into account, the best way to sort is( )A. Merge sortB. Insertion sortC. Straight selection sortD.Quicksort二.Fill the blanks1.In order to insert a new node s after the node which pointer q points to in a circular doubly linked list, we need to execute the followingstatements:s->prior=q; s->next=q->next; _____________________;q->next=s;2.In the doubly linked list, if d is a pointer points to a node in the list, then:d->next->__________=d->prior->__________=__________;3.Stack can be considered as an operation restricted linked list ,one end that can insert and remove is called _____________。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Examination Paper on Data StructureⅠ Fill Vacant Position ()1.In a ________ data structure, all insertions and deletions of entries are made atone end. It is particularly useful in application involving________.2.In processing a sequential list with n entries: insert and remove require timeapproximately to ________.3.One of method of searching is ________ that requires ordered list.4.The time complexity of the quicksort is ________.5.Only ________ ________ graph has topological order.6.According the definition of Binary Tree, there will be ________ differentBinary Trees with 5 nodes.ⅡSingle choice ()1.The Linked List is designed for conveniently ________data item.a. gettingb. insertingc. findingd. locating2.Assume a sequence list as 1,2,3,4,5,6 passes a stack, an impossible outputsequence list Is ________ .a. 2,4,3,5,1,6b.3,2,5,6,4,1c.1,5,4,6,2,3d.4,5,3,6,2,13. A queue is a structure not implementing ________.a. first-in/first-outb. first-in/last-outc. last-in/last-outd. first-come/first-serve4.Removing the data item at index i from a sequential list with nitems, ________ items need to be shifted left one position.a. n-ib. n-i+1c. id. n-i-15.The addresses which store Linked List ________ .a. must be sequentialb. must be partly sequentialc. must be no sequentiald. can be sequential or discontiguous6.The time requirement of retrieving a given target in hash table with n entriesis _______a. O(n)b. O(log2n)c. O(1)d. O(nlog2n)7.If the Binary Tree T2 is transformed from the Tree T1, then the postorder ofT1 is the ________ of T2.a. preorderb. inorderc. postorderd. level order8.In the following sorting algorithm, ________ is an unstable algorithm.a. the insertion sortb. the bubble sortc. quicksortd. mergesort9.Assume there is a ordered list consisting of 100 data items, using binarysearch to find a special item, the maximum comparisons is ________ .a. 25b.1c. 10d.710.The result from scanning a Binary Search Tree in inorder traversal isin ________ order.a. descending or ascendingb. descendingc. ascendingd. out of order11.The ________ case is worst for quicksort.a. the data which will be sorted is too larger.b. there are many same item in the data which will be sorted .c. the data will be sorted is out of orderd. the data will be sorted is already in a sequential order12.In a Binary Tree with n nodes, there is ________ non-empty pointers.a. n-1b. n+1c. 2n-1d.2n+113.In a undirected graph with n vertexs, the maximum edges is _______.a. n(n+1)/2b. n(n-1)/2c. n(n-1)d.n/214.The output from scanning a minimum heap with level traversalalgorithm _______.a. must be an ascending sequence.b. must be descending sequencec. must have a minimum item at the head position.d. must have a minimum item at the rear position.15.Assume the preorder of T is ABEGFCDH, the inorder of T is EGBFADHC,then the postorder of T will be _______.a. GEFBHDCAb. EGFBDHCAc. GEFBDHCAd. GEBFDHCA16.When a recursive algorithm is transformed into a no recursive algorithm, astructure _______ is generally used.a. SeqListb. Stackc. Queued. Binary Tree17.Among sorting algorithms, _______ kind of algorithm is divide-and–conquer sorting.a. shell sortb. heap sortc. merge sortd. inserting sortⅢcomprehensive problem( )1. For the following binary tree, give the result of traversing under postorder2.Assume a list is {48,35,64,92,77,13, 29,44}, firstly insert these items to an emptycomplete Binary Tree according to the sequence one by one, then please heapify the complete Binary Tree and implement the heap sort. Please draw the whole heapigying process and sorting process.3. For the following directed graph, give the adjacency matrix and adjacency list. Then according your adjacency list, please scan the graph using the depth-first search and the breadth-first search and give the corresponding result.4. Suppose that(a ) A hash table contains hash_size = 16 position indexed from 0 to 15(b) A hash function H(key)=(key * 3) % 13(c) The following keys are to be mapped into the table:10 120 33 45 58 26 3 27 200 400 2 Draw the hash table with the collision resolution of linear probing.5. Construct a minimal spanning tree of the following connected network.Ⅳ Programming.1. Assume there are two ascending ordered linked lists L1 and L2, please merge L1 and L2 into a new link list L3. There will be no duplicate items in L3. Then please reverse the L3 into a descending ordered list.For linked list, we have the following class specifications:Template<class Entry>struct Linknode{Elemtype data;Linknode< Elemtype > *next;};Template<class Entry>class Linklist{public: A B H E G C D Fvoid Mergelist(const Linknode <Elemtype> &A, const Linknode< Elemtype > &B, Linknode < Elemtype > &C );private:Linknode< Elemtype > *head;};Write the function Mergelist;2 .For linked implementation of binary trees, we have the following class specifications: template<class Entry>Struct Binary_node{Entry data;Binary_node<Entry > * lchild;Binary_node<Entry > *rchild;};Class Binary_tree{Protected:Binary_node<Entry > *root;int recursive_heght( Binary_node<Entry > *sub_root);Public:int height();};Template <class Entry >int Binary_tree<Entry > :: height(){recursive_height(root);}Write the function recursive_height to compute height of a binary tree.。

相关文档
最新文档