卷別
資料結構與演算法
選擇國立臺灣大學 2025 · 考試 · 第 13 題
考科演算法
(5 points) Consider the (incomplete) pseudocode snippet SOLVE().
1: function SOLVE(G = (V, E, w), s, r)
2: P = V ▷ Initializes all vertices.
3: Set A[s] = 0 and A[x] = ∞ for all x ≠ s. ▷ Initializes an array A.
4: while P ≠ ∅ do
5: x = argmin_{x ∈ P} A[x] ▷ Chooses a vertex.
6: P = P − {x} ▷ Removes the vertex.
7: for each y ∈ P such that {x, y} ∈ E, do
8: (*)
9: return (**)
You have realized that this code snippet can be used to solve different problems by filling the blanks in different ways. Here are three problems to consider:
- In the ST-DISTANCE problem, you are given a graph with non-negative weights, and two vertices . The goal is to compute the shortest distance between and .
- In the ST-BOTTLENECK problem, you are given a graph with non-negative weights, and two vertices . The goal is to compute the smallest possible weight such that there exists at least one path from to using only edges whose weights are less than or equal to .
- In the MST problem, you are given an undirected, weighted, and connected graph . The goal is to compute the total weight of a minimum spanning tree.
Select all correct statement(s) below.
- (A)To solve ST-DISTANCE, we fill with , and we fill with .
- (B)To solve ST-BOTTLENECK, we fill with , and we fill with .
- (C)To solve MST, we fill with , and we fill with .
- (D)The code snippet can be implemented with Fibonacci heaps, so there exist algorithms with running time for all three problems stated above.
- (E)The value will always be non-negative in any correct implementation for solving any of the problems stated above.