MOOC-Chen Yue and he qinming-Data Structure-2016 autumn mid-term examination, mooc-2016
Question:
1-1
Two main aspects of algorithm analysis are time complexity and space complexity analysis. (2 points)
1-2 store N data in a one-way linked list in ascending order. If binary search is used, the average time complexity of the search is O (logN ). (3 points) 1-3 through stack S operations: Push (S, 1), Push (S, 2), Pop (S), Push (S, 3 ), pop (S), Pop (S ). The output sequence is 123. (3 points) 1-4 the so-called "cyclic queue" refers to a queue represented by a one-way cyclic linked list or cyclic array. (2 points) 1-5 search for 63 in a binary search tree, sequence 39, 101, 25, 80, 70, 59, and 63 are possible comparison sequences of node values during search. (3 points) 1-6 inserts the values of 1, 2, 3, 4, 5, and 6 into the AVL tree with an initial null value. After inserting these six elements, the first traversal result of the AVL Tree is 4, 2, 1, 3, 5, and 6. (3 points) 1-7 A Complete Binary Tree with 124 nodes, the number of its leaf nodes is determined. (3 points) 1-8 uses the adjacent table method to store graphs. The number of storage space occupied is only related to the number of nodes in the graph, but not the number of edges. (3 points) 1-9 if the undirected graph G must perform two breadth-first searches to access all its vertices, then G must have a loop. (3 points) 1-10 if the pre-order and mid-order traversal sequences of a binary tree are exactly the same, no node in the binary tree must have the right child. (3 points)
Multiple choice questions:2-4
Set h to a one-way linked list with no leading nodes. The statement for inserting a new node t on the head of h is: (4 points)
A, h = t; t-> next = h-> next;
B. t-> next = h-> next; h = t;
C, h = t; t-> next = h;
D, t-> next = h; h = t; 2-5
If the infix expression a + B * c + (d * e + f) * g is converted into a suffix expression by using the stack, what is the content in the stack (in the ascending order of stack bottom )? (4 points)
A, + (* +
B, + (+
C, ++ (+
D. abcde 2-6
If you use an array of 6 to implement a cyclic queue, and the current front and rear values are 0 and 4, respectively. What are the values of front and rear after two elements are deleted from the queue and then added? (4 points)
A, 2, and 0
B, 2, and 2
C, 2, and 4
D, 2, and 6 2-7
In the Sankey tree, there are five knots with a degree of 1, three knots with a degree of 2, and two knots with a degree of 3. How many leaf knots does the tree contain? (4 points)
A, 8
B, 10
C, 12
D, 13 2-8
If ABC is the result of the first traversal of a binary tree, which of the following sequence is not the result of the middle traversal? (4 points)
A. ABC
B. BAC
C. CBA
D. CAB 2-9
In a Complete Binary Tree represented by an array, if the root node subscript is 1, where are the closest common ancestor nodes of the subscripts 17 and 19 (array subscript )? (Note: the "common ancestor node" of the two nodes refers to the node that is also the ancestor of the two nodes) (4 points)
A, 8
B, 4
C, 2
D, 1 2-10
Insert the values 6, 4, 3, 5, 8, and 9 to the largest heap (large root heap) with an initial null value. The element at the top of the heap after the insertion is: (4 points)
A, 3
B, 5
C, 6
D, 9 2-11
If a piece of text contains characters {a, B, c, d, e}, the occurrence frequency is {3, 2, 5, 1, 1 }. The number of bytes occupied by the text is 4 points after the user's coding)
A, 40
B, 36
C, 25
D, 12 2-12
The collection element 0 ~ is known in the Union query ~ 8. Therefore, the numbers of the corresponding parent nodes are {1,-4, 1, 1,-3, 4, 4, 8,-2} (note: -n−n indicates the root of the tree and the corresponding set size is nn). After merging the collection of elements 6 and 8 (the small set must be merged into a large set, what are the numbers of the root and parent nodes corresponding to this set? (4 points)
A, 1, and-6
B, 4, and-5
C, 8, and-5
D, 8, and-6
Program blank question:3-1 the following code functions from a large top heap
H
At a specified position of p to start filtering.
1 void PercolateDown (int p, PriorityQueue H) 2 {3 int child; 4 ElementType Tmp = H-> Elements [p]; 5 (; p * 2 <= H-> Size; p = child) {6 child = p * 2; 7 if (child! = H-> Size & 8 9 (6 points) 10 child ++; 11 if (H-> Elements [child]> Tmp) 12 13 14 (6 points ); 15 else break; 16} 17 H-> Elements [p] = Tmp; 18}
3-2 The following code returns the reverse linked list of the single-chain table L of the leading node.
1 List Reverse (List L) 2 {3 Position Old_head, New_head, Temp; 4 New_head = NULL; 5 Old_head = L-> Next; 6 7 while (Old_head) {8 Temp = Old_head-> Next; 9 10 (6 points); 11 New_head = Old_head; 12 Old_head = Temp; 13} 14 15 (6 points); 16 return L; 17}
Reference answer:Answer: tffff ttfff multiple choice question: cacdb aadbd cb program fill blank question: h-> Elements [child + 1]> H-> Elements [child] H-> Elements [p] = H-> Elements [child] Old_head-> Next = New_head L-> Next = New_head