Consider an undirected graph G=(V,E), an edge is a relation over the vertices; the relation is reflexive, symmetric, and transitive. Computing the connected components in the G is the same as to compute the equivalence classes of the vertices, V. Let the number of vertices be n and the number of edges be m.
(25) Which of the following statement(s) is(are) true? (a) Both breadth first search and Union/Find algorithm can compute the equivalence classes. (b) Both depth first search and breadth first search can compute the equivalence classes. Performance of depth first search is better than the breadth first search. (c) If graph G is big (large m and large n), among the breadth first search, depth first search, and Union/Find, we should choose depth first search because of space consideration. (A) (a) and (b) are true, but (c) is not. (B) (a) and (c) are true, but (b) is not. (C) (b) and (c) are true, but (a) is not. (D) all of (a), (b), and (c) are true. (E) Only (a) is true.
(26) Union/Find implements set operations by using forest. A set is a rooted tree where the root presents the set. Recall that there are n vertices and m edges. About computing the equivalence classes, which of the statement(s) is(are) true. (a) Union operation can be done in O(1) time, there are at most m Unions. (b) The time required by Find(i) operation depends on the path length from i to the root. There are at most m Finds. (c) Applying weighting rule for Union, the time required for a Find is bounded above by O(log n). Applying collapsing rule for Find, the path length can be further reduced. (A) (a) and (b) (B) (a) and (c) (C) (b) and (c), (a) is not (D) all (E) Only (a)
(27) Function f₁(k)=2^k, f₁ is the exponential function. Function f₂(k)=pow(2,pow(2,pow(2,…pow(2,2)))), a tower of power of 2, and the height of the tower is k. If n=f₁(k), then k=log n. If n=f₂(k), we say k=log* n. Which of the following statement(s) is(are) true? (a) f₂(k) grows faster than f₁(k). (b) log* n grows faster than log n. (c) According the speed of growth of the functions, we have n log n > n log* n > n^a, where 1
(25) (a) BFS 與 Union/Find 都能算 connected component(equivalence class) → T;(b) DFS 與 BFS 都可以,但 DFS 並沒有比較快(都是 \(O(n+m)\)) → F;(c) DFS/BFS 都要存整張圖與 stack/queue,Union/Find 只要 \(O(n)\) 的 parent array,大圖該選 Union/Find,不是 DFS → F → (E)
(26) (a) Union 只要兩個 root 就是 \(O(1)\),但實際成功的 Union 至多 \(n-1\) 次(不是 \(m\) 次;\(m\) 次是 Union 的呼叫數) → 敘述不成立(官方答案此項為 F);(b) Find 的時間由路徑長決定,至多 \(m\) 次(兩端各一次,\(2m\)) → T;(c) weighting rule 使樹高 \(O(\log n)\),collapsing rule 再縮短路徑 → T → (C)
(27) (a) tower 的成長遠快於 \(2^k\) → T;(b) \(\log^*n\) 長得比 \(\log n\) 慢得多 → F;(c) \(n^a\)(\(a\gt1\))的成長比 \(n\log n\) 快,次序寫反了 → F → (E)
(25) E (26) C (27) E