資料結構及演算法
國立政治大學 2025 · 考試 · 17 題
整卷連續作答,作答時答案與解析隱藏;按「交卷」後揭曉正解、標準解析並自動批改(申論/計算題不計分,供自行對照)。
- 第 1 題選擇
(4%) Let an be the sizes of two sets, assume , if the sets are implemented using sorted lists, what is the time complexity to find the intersection of the two sets?
- 第 2 題選擇
(4%) Consider again the above question, what if the sets are implemented using AVL trees, instead of sorted lists?
- 第 3 題選擇
(4%) If an array is used to implement a binary search tree with nodes, where index 1 (the first position) of the array stores the root, what is the maximal index that stores the smallest key in the tree?
- 第 4 題選擇
(4%) Which of the following statement concerning hashing is false?
- 第 5 題選擇
(4%) Given a logical expression represented as an expression tree, along with the Boolean values assigned to the operands, which algorithm is best suited to evaluate the logical expression?
- 第 6 題選擇
(4%) Given the following algorithm, which is likely to be the result if the input variable N is -1?
Boolean Magic (int N) { if (N==1) Return True else if (N==0) Return False else { N = N-2; Return Magic(N); }; } - 第 7 題選擇
(4%) Which sorting algorithm will produce the following results of pass 0, 1 and 2 for 33, 7, 63, 50, 31, 20?
Pass 0: 7, 33, 63, 50, 31, 20 Pass 1: 7, 20, 63, 50, 31, 33 Pass 2: 7, 20, 31, 50, 63, 33 - 第 8 題選擇
(4%) If an array is used to implement a max-heap, where index 1 (the first position) of the array stores the root, what is the maximal index that stores the 3rd ranked element?
- 第 9 題選擇
(4%) Given an undirected connected graph of vertices and edges, which of the following statement concerning spanning trees is false?
- 第 10 題選擇
(4%) Given an undirected graph of vertices, edges and connected components, what is the minimum number of edges required to make this graph connected?
- 第 11 題選擇
(4%) Which of the following statements concerning topological ordering is true?
- 第 12 題選擇
(4%) Which of the following statements concerning time complexity is false?
- 第 13 題選擇
(4%) Which of the following statements concerning reduction is false?
- 第 14 題選擇
(4%) Which of the following statements is false?
- 第 15 題選擇
(4%) Which of the following problems is NP-Hard?
- 第 16 題計算
Six Degrees of Separation is the theory that any person on the planet can be connected to any other person on the planet through a chain of acquaintances that has no more than five intermediaries on average. For example, in the social network graph below (Figure 1), the degree of separation between Gia and Felix is five. They can be connected by at least four intermediaries. The average degree of separation in this social network is about 2.1. Given a dense social network of persons, design a dynamic programming algorithm to compute the average degree of separation in this social network.
Figure 1 (undirected social network graph): vertices with edges .
(1) (10%) Give the algorithm in pseudo code clearly.
(2) (5%) Give the recurrence relation.
(3) (5%) Analyze the time complexity of your algorithm.
- 第 17 題計算
Please design an algorithm to search for the -th element in an AVL tree of elements, while the time complexity of insertion operation remains .
(1) (5%) How to modify the data structure of an AVL tree to support this search operation?
(2) (10%) Give the algorithm to search for the k-element.
(3) (5%) How to modify the insertion operation to accommodate for the modification of the data structure.
(Please illustrate your answer by using the AVL-tree provided in Figure 2.)
Figure 2 (AVL tree): root ; left child , right child ; 's children are (left) and (right); 's children are (left) and (right); 's left child is .