← 回題庫

卷別

資料結構與演算法

選擇

國立臺灣大學 2024 · 考試 · 第 12 題

考科演算法

(5 points) Consider a directed acyclic graph G=(V,E)G = (V, E) of nn tasks where every node is a task and every edge is a dependency. If there is an edge from a task vv to another task ww, that means we need to finish vv before starting ww. We have pp processors of the same capability and every processor can finish any task in one unit of time.

We define a schedule function ss to map a task vv to a positive integer time step s(v)s(v). Since we have only pp processors, so the system can only process at most pp tasks in one time step. Also, a schedule needs to respect the dependency of edges.

  • (A)
    For every positive integer ii, ∣{v∣s(v)≤i}∣≤p|\{v \mid s(v) \le i\}| \le p.
  • (B)
    If there is a path (vi1,…,vik)(v_{i_1}, \dots, v_{i_k}) in GG, then s(vij)<s(vik)s(v_{i_j}) < s(v_{i_k}) for 1≤j≤k1 \le j \le k.
  • (C)
    The number of time steps required is at least min⁡(⌈n/p⌉,L)\min(\lceil n/p \rceil, L), where LL is the number of tasks along the longest path in GG.
  • (D)
    Without loss of generality, we can always assume s(v)=1s(v) = 1 for all vv's without incoming edges.
  • (E)
    If the number of processors is infinite, then we can finish all tasks in LL time steps, where LL is the number of tasks along the longest path in GG.

標準解析

AI 已複查