卷別
資料結構與演算法
選擇國立臺灣大學 2026 · 考試 · 第 24 題
考科演算法
(4 points) Let be a directed graph represented using adjacency lists without edge weights. We run BFS from a source , producing distance labels for each reachable vertex . Which of the following statements is always true?
- (A)For every edge , we must have .
- (B)If , then must be a tree edge in the BFS tree.
- (C)BFS always produces a shortest-path tree that is also a topological ordering of the reachable subgraph.
- (D)If the graph is represented by an adjacency matrix instead of adjacency lists, BFS may compute incorrect distances that lead to repeated relaxations.
- (E)If BFS discovers vertices in the order , then this order is a shortest-path ordering for all pairs of vertices.