### 一、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.

 Activity From state To state Time $a_1$ 1 2 5 $a_2$ 1 3 5 $a_3$ 2 4 3 $a_4$ 3 4 6 $a_5$ 3 5 3 $a_6$ 4 6 4 $a_7$ 4 7 4 $a_8$ 4 5 3 $a_9$ 5 7 1 $a_{10}$ 5 8 4 $a_{11}$ 6 10 4 $a_{12}$ 7 9 5 $a_{13}$ 8 9 2 $a_{14}$ 9 10 2

(a) 22
(b)
1: $a_2 \rightarrow a_4 \rightarrow a_8 \rightarrow a_9 \rightarrow a_{12} \rightarrow a_{14}$
2: $a_2 \rightarrow a_4 \rightarrow a_8 \rightarrow a_{10} \rightarrow a_{13} \rightarrow a_{14}$
3: $a_2 \rightarrow a_4 \rightarrow a_7 \rightarrow a_{12} \rightarrow a_{14}$

### 二、Algorithms (50%)

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

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

$$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}$$

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})$
$$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}$$

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];

### 2 留言

1. #### Jackson

您好，請問一下，Data Structure critical path 只有那兩條嗎 ?
我看 a2 → a4 → a7 → a12 → a14 也是 22 = 5 + 6 + 4 + 5 + 2