考試

101成大資工程設[參考解答]

一、Data Structure (50%)

1. (20%) Let $S_n$ be the expected number of comparison in a successful search of a randomly constructed n-node binary tree, and let $U_n$ be the expected number of comparisons in an unsuccessful search. We assume that $H_n$ is the n-th harmonic number. Please represent $S_n$ and $U_n$ respectively using harmonic number.

參考解答:


2. (30%) For the AOE (Activity on Edge) network described by the table, (a) What is the earliest time the project can finish? (b) Please list all critical paths. Note that state 1 is the starting state and state 10 is the goal state.

ActivityFrom stateTo stateTime
$a_1$125
$a_2$135
$a_3$243
$a_4$346
$a_5$353
$a_6$464
$a_7$474
$a_8$453
$a_9$571
$a_{10}$584
$a_{11}$6104
$a_{12}$795
$a_{13}$892
$a_{14}$9102

參考解答:
(a) 22
(b)
1: $a_2 \rightarrow a_4 \rightarrow a_8 \rightarrow a_{10} \rightarrow a_{13} \rightarrow a_{14}$
2: $a_2 \rightarrow a_5 \rightarrow a_{10} \rightarrow a_{13} \rightarrow a_{14}$


二、Algorithms (50%)

1. (20%) Solving the recurrence $T(n) = 2T(n/4) + \sqrt{n}$ using $\Theta$ notation.

參考解答:$\Theta (\sqrt{n} lgn)$


2. (20%) The incident matrix of a directed graph $G=(V,E)$ with no self-loops is a $|V| \times |E|$ matrix $B = (b_{ij})$ such that

$$
\begin{equation}
b_{ij} =
\begin{cases}
-1 & \text{if edge $j$ leaves vertex $i$}\\
1 & \text{if edge $j$ enters vertex $i$}\\
0 & \text{otherwise}
\end{cases}
\end{equation}
$$

Describe what the entries of the matrix product $BB^T$ represent, where $B^T$ is the transpose of $B.$

參考解答:
Let $A = BB^T = (a_{ij})$
$$
\begin{equation}
a_{ij} =
\begin{cases}
v_i \text{‘s } indeg() + outdeg() & i = j\\
-1 \times \text{edges between } v_i \text{ and } v_j & i \neq j
\end{cases}
\end{equation}
$$


3. (10%) The Fibonacci numbers are defined by recurrence

$F_0 = 0,$
$F_1 = 1,$
$F_i = F_{i-1} + F_{i-2}$ for $i \geq 2.$
Give an $O(n)$-time dynamic-programming algorithm to compute the nth Fibonacci number.

參考解答:

array f[0...n]; f[0] = 0; f[1] = 1; for i = 2 to n: f[i] = f[i - 1] + f[i - 2]; return f[n];
Code language: plaintext (plaintext)

題目(pdf):連結

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

發佈留言