Reference answer 1. No question (10 points for each question) 1. The chain storage structure of a linear table is superior to that of a sequential storage structure. F2. the stack and queue are also linear tables. If needed, you can operate on any of them. The F3. string is a linear table specific to the data object. T4. Insert the S node after the P pointer of a single-chain table: p-> next = s; s-> next = p-> next; f5. the connected component of an undirected graph is its extremely large connected subgraph. The T6. adjacent table can represent a directed graph or an undirected graph. T7. suppose B is a tree, and B 'is the corresponding binary tree. Then, the back root traversal of B is equivalent to the middle-order traversal of B. T8. generally, layer I of a binary tree has 2 I-1 nodes. F9. for a m-Level B-tree, each node in the tree has up to M keywords. All non-terminal nodes except the root node have at least e m/2 keywords. F10. for any sequence to be sorted, fast sorting is faster than Bubble sorting. F II. multiple choice questions (each question has two points for a total of 28 points) 1. among the following sorting methods, the average time complexity of the (c) method is 0 (nlogn), and the worst case is 0 (N2); (d) in all cases, the time complexity is 0 (nlogn ). A. Insert sort B. Hill sort C. Fast sort D. Heap Sort 2. In the binary linked list with N nodes, the number of null pointers is (B ). A. May not B. N + 1 C. N D. n-13. In the following Binary Tree, (a) can be used to realize symbol unequal length efficient coding. A. Optimal Binary Tree B. sub-optimal search tree C. Binary balancing tree D. Binary sorting tree 4. In the following search method, (a) is suitable for searching ordered Single-Chain tables. A. search for B in sequence. binary Search C. block search D. hash search 5. in order to avoid checking whether the entire table has been searched in every step of the search process, you can use the (a) method. A. set monitoring record B. linked List storage C. binary Search D. quick Search 6. in the following data structures, (c) has the first-in-first-out feature, and (B) has the first-in-first-out feature. A. Linear Table B. Stack C. queue d. Generalized Table 7. Binary sorting tree with M nodes. Its maximum depth is (F) and the minimum depth is (B ). A. log 2 m B. └ log2 M memory + 1 C. m/2D. memory M/2 memory-1 E. running M/2 then f. M 8. the keywords of a group of records to be sorted are listed as follows:, 34. (C) is the result of a quick sort. (B) is the result of a one-stop sorting by hill (the initial step is 4. (D) It is the result of a base sort. (A) is the initial heap (large heap top ). A., 56. B., 64. C., 57. D. E. 34,56, 26,58, 52,64, 37,28, 79,57, 84. F. 34,56, 64, 57. 3. Fill in blank questions (20 points in total for each question) 1. The storage structure of Directed Graphs includes (Adjacent matrix), (adjacent table), and (cross linked list. 2. We know that the first traversal order of a binary tree is afbcdeg, and the middle traversal order is cedbgfa. The subsequent traversal order is (edcgbfa ). The traversal order is (afbcgde ). 3. A two-dimensional array a 5x7 is provided. Each element is stored in 4 adjacent bytes, and the memory is encoded in bytes. The storage address of a00 is 100. For row-based storage, the address of the first byte of element A14 is (144); for column-based storage, the address of the first byte of element A14 is (184 ). 4. Fill in the appropriate statement on the underline to complete the following calculation. Status preordertraverse (bitree T, status (* visit) (telemtype E) {// The first-order non-recursive traversal of the binary tree. Initstack (s); push (S, T); While (! Stackempty (s) {While (gettop (S, P) & P) {visit (p-> data); push (S, P-> lchild ;} pop (S, P); If (! Stackempty (s) {Pop (S, P); push (S, P-> rchild) ;}} Return OK; 4. short answer questions (a total of 25 points for each question) 1. converts the graph forest to a binary tree, and returns clues in the ascending order of the binary tree. H D A JI B F E C ML K G 2. the hash function is known to be H (K) = K mod 13, and the hash address is 0 -- 14. The hash address is used for secondary detection and re-hash to handle conflicts. The keywords (, 49,, 55) distribution in the hash address. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 143. The right figure shows a Level 3 B tree. () A. Plot the B tree after inserting element 15 into the tree. /│ \ B. Then, delete element 35 and draw the deleted B tree. () (21) (35) 4. The storage structure of an undirected graph is known. A. Draw the graph. B. The depth-first traversal sequence and breadth-first traversal sequence are given based on the storage structure. C. Draw the depth-first spanning tree and breadth-first spanning tree. 0 A 2 4 // 1 B 2 3 4 // 2 C 0 1 4 // 3 D 1 // 4 E 0 1 2 //5. A communication system uses eight characters, which are 0.08, 0.05, 0.1, 0.12, 0.26, 0.18, 0.14, 0.07, and characters, and provides the Heman encoding. 5. algorithm design question (17 points in total) 1. the type of a Single-linked table node is defined as follows: typedef struct lnode {int data; struct lnode * Next;} lnode, * linklist; write an algorithm, combine the ordered Single-Chain tables A and B of the leading node into a new ordered table C. (Note: the original structure of A and B is not damaged .) merge (linklist A, linklist B, linklist & C) void Merge (linklist A, linklist B, linklist & C) {c = (linklist) malloc (sizeof (lnode )); pa = A-> next; Pb = B-> next; Pc = C; while (PA & Pb) {PC-> next = (linklist) malloc (sizeof (lnode); Pc = pc-> next; If (Pa-> data <= Pb-> data) {PC-> DATA = pa-> data; pa = pa-> next;} else {PC-> DATA = Pb-> data; Pb = Pb-> next;} If (! Pa) pA = Pb; while (PA) {PC-> next = (linklist) malloc (sizeof (lnode); Pc = pc-> next; PC-> DATA = pa-> data; Pa = pa-> next;} PC-> next = NULL;} 2. binary Trees are stored in binary linked lists. Typedef struct bitnode {telemtype data; struct bitnode * lchild, * rchild;} bitnode, * bitree; write a recursive algorithm that copies a binary tree. Bitree copytree (bitree t) {If (! T) return NULL; If (! (Newt = (bitnode *) malloc (sizeof (bitnode) Exit (overflow); newt-> DATA = T-> data; newt-> lchild = copytree (t-> lchild); newt-> rchild = copytree (t-> rchild); Return Newt; |