Consider the following pseudocode for depth-first search (DFS) algorithm which
takes a directed graph πΊ(π, πΈ) as input, where π[π£] and π[π£] are the discovery time
and finishing time, respectively, of the vertex π£ βπ.
π·πΉπ(πΊ):
π’πππππ πππ π£βπ
π‘ β0
πππ πππβ π£βπ
ππ π£ ππ π’πππππππ
π‘βπΈπ₯πππππ(πΊ, π£, π‘)
πππ ππ
πππ πππ
πΈπ₯πππππ(πΊ, π£, π‘):
ππππ π£
π‘ βπ‘+ 1
π[π£] βπ‘
πππ πππβ (π£, π€) βπΈ
ππ π€ ππ π’πππππππ
π‘βπΈπ₯πππππ(πΊ, π€, π‘)
πππ ππ
πππ πππ
π‘ βπ‘ + 1
π[π£] βπ‘
πππ‘π’ππ π‘
Suppose that the input directed graph πΊ(π, πΈ) is a directed acyclic graph (DAG).
For an edge (π’, π£) βπΈ, which of the following options will NEVER be correct?
This question tests the Parenthesis Theorem of DFS timestamps applied to a directed acyclic graph (DAG). For any edge \((u, v) \in E\) discovered during a DFS run, the discovery time \(d[\cdot]\) and finishing time \(f[\cdot]\) of \(u\) and \(v\) must satisfy one of a fixed set of relationships depending on the type of edge (tree/forward, back, or cross).
Step 1: Recall the Parenthesis Theorem.
In any DFS, for two vertices \(u\) and \(v\), the intervals \([d[u], f[u]]\) and \([d[v], f[v]]\) are either completely disjoint or one is completely nested inside the other. They can never partially overlap.
Step 2: Classify edge \((u, v)\) by DFS timestamp pattern.
Case 1 (Tree/Forward edge): \(u\) is an ancestor of \(v\) in the DFS forest, so \(v\)'s interval is nested inside \(u\)'s interval: \[d[u] < d[v] < f[v] < f[u]\] This is option A, and it is perfectly valid, so it is not the answer.
Case 2 (Cross edge): \(v\) is explored and completely finished before \(u\) is even discovered, so the intervals are disjoint with \(v\)'s interval entirely before \(u\)'s: \[d[v] < f[v] < d[u] < f[u]\] This is option C, and cross edges are valid in a DAG, so it is not the answer.
Case 3 (Back edge): \(v\) is an ancestor of \(u\), meaning \(v\)'s interval nests \(u\)'s interval: \[d[v] < d[u] < f[u] < f[v]\] This is exactly option B. A back edge implies a cycle in the graph (since \(v\) is an ancestor of \(u\) but there is also an edge \(u \to v\)). Since \(G\) is given to be a DAG, back edges cannot exist. Hence option B can never occur.
Step 3: Check option D.
Option D states \[d[u] < d[v] < f[u] < f[v]\] Here \(u\)'s interval starts before \(v\)'s, but \(u\) finishes before \(v\) finishes while \(v\) started after \(u\). This means the two intervals partially overlap: \(d[v]\) falls inside \(u\)'s interval, but \(f[v]\) falls outside it. This directly violates the Parenthesis Theorem, which forbids partial overlap between any two DFS intervals, regardless of whether an edge connects the vertices or whether the graph is a DAG. So option D is structurally impossible in any DFS run.
Step 4: Conclusion.
Option A (tree/forward edge pattern) and option C (cross edge pattern) are both valid and can occur. Option B (back edge pattern) cannot occur only because the graph is acyclic. Option D (overlapping intervals) can never occur in any DFS on any graph, because it violates the fundamental nesting property of DFS timestamps.
Hence the options that will NEVER be correct are B and D.
Final Answer:
\[\boxed{\text{Options B and D}}\]
A schedule of three database transactions \(T_1\), \(T_2\), and \(T_3\) is shown. \(R_i(A)\) and \(W_i(A)\) denote read and write of data item A by transaction \(T_i\), \(i = 1, 2, 3\). The transaction \(T_1\) aborts at the end. Which other transaction(s) will be required to be rolled back?
