考試

110成大電機資結[參考解答]

1. For a two dimensional array $A$, if the location of $A(4, 3)$ is 1000 and $A(3, 5)$ is 1013. Assume that each element occupies 1 address. What is the location of $A(2, 2)$? (10%)

參考解答:991


2. Which of the choices DO NOT contain two equivalent expressions? Note that A^B is $A^B$. (15%)

(a) Infix    A+B-C            Prefix  -+ABC
(b) Postfix  AB+CD-*          Prefix  *+AB-CD
(c) Postfix  AB^C*D-EF/GH+/+  Prefix  +-*^ABCD//EF+GH
(d) Postfix  AB+C*DE--FG+^    Prefix  ^-*+ABC-DE+FG
(e) None of the above

參考解答:(e)


3. Read the following data in the given order: (30%)

$$55, 45, 25, 35, 85, 95, 65, 75, 105, 15$$

(a) If you create a max heap for them, what will be the value in root? (10%)
(b) If you create a 2-3 tree for them, what will be the value in root? (10%)
(c) If you create an AVL tree for them, what will be the value in root? (10%)

參考解答:(a) 105 (b) 65 (c) 45


4. Use the Bellman-Ford algorithm, STEP BY STEP, to find the shortest path and the length from node 0 to node 6 in the following graph. Note that you get 0 point without showing the result after each step. (15%)

$$圖片請看原檔$$

參考解答:


5. Consider the merge sort and quick sort. Let $L_{1}$ and $L_{2}$ be two sorted lists of $m$ and $n$ elements, respectively. (15%)

(a) What is the maximum number of comparisons needed for merging $L_{1}$ and $L_{2}$? (5%)
(b) What is the minimum number of comparisons needed for merging $L_{1}$ and $L_{2}$? (5%)
(c) Both merge sort and quick sort are suitable for external sorting. Right? Explain your answer. (5%)

參考解答:
(a) $m + n – 1$
(b) $min(m, n)$
(c) No, only merge sort is suitable for external sorting.


6. Describe three key points for designing a good hashing function. (15%)

參考解答:
1. Simple and Fast
2. The less collision the better
3. The hash function uniformly distributes the data across the entire set of possible hash values


試題(pdf):連結

有任何問題,或想要完整解釋的,歡迎在下方留言唷!

發佈留言