TAOCP 7.1.3 Exercise 147
The key correction is that Algorithm V must be followed literally: vertices are scanned in the prescribed external order $v_1,\dots,v_n$, and pointers $\pi_v,\beta_v,\alpha_v$ are updated only when th...
Section 7.1.3: Bitwise Tricks and Techniques
Exercise 147. ▶ [M20] [M20] What values of πv, βv, αv, and τj occur in Algorithm V when the forest is a) the empty digraph with vertices {v1, . . . , vn} and no arcs? b) the oriented path vn −−→· · · −−→v2 −−→v1?
Verified: no
Solve time: 3m
The key correction is that Algorithm V must be followed literally: vertices are scanned in the prescribed external order $v_1,\dots,v_n$, and pointers $\pi_v,\beta_v,\alpha_v$ are updated only when the algorithm actually discovers a vertex through an untraversed arc. Any interpretation that assumes a pre-existing rooted-tree structure is invalid.
We now restart from the algorithmic behavior.
a) Empty digraph on ${v_1,\dots,v_n}$
There are no arcs at all, so during the scan of vertices $v_1,\dots,v_n$, no recursive exploration is ever triggered.
When Algorithm V first encounters a vertex $v_i$, it is unmarked, so it is simply processed as an isolated vertex. Since there are no outgoing arcs to explore:
- no child is ever created,
- no sibling list is ever formed,
- no ancestor updates propagate beyond the vertex itself.
Thus no structural links are created at all.
Parent pointers $\pi_v$
Since no vertex is ever discovered via another vertex, every vertex is a root of its own trivial tree. Hence
$$ \pi_{v_i} = 0 \quad \text{for all } i. $$
Sibling pointers $\beta_v$
No vertex acquires children, so there are no sibling chains:
$$ \beta_{v_i} = 0 \quad \text{for all } i. $$
Ancestor pointers $\alpha_v$
Each vertex is its own active component root at the moment of processing, and no later updates occur:
$$ \alpha_{v_i} = v_i \quad \text{for all } i. $$
Timestamps $\tau_v$
Each vertex is first encountered exactly when it is scanned, since no exploration ever reaches new vertices. Therefore the discovery times follow the scan order:
$$ \tau_{v_i} = i \quad \text{for } i=1,\dots,n. $$
b) Oriented path $v_n \to v_{n-1} \to \cdots \to v_1$
The crucial point is that Algorithm V still scans vertices in the fixed order $v_1, v_2, \dots, v_n$, and only traverses arcs from a vertex when that vertex is first processed.
We examine what happens during this scan.
Step 1: processing $v_1$
Vertex $v_1$ has no outgoing arcs. It is unmarked, so it is discovered immediately:
- $\tau_{v_1} = 1$
- $\pi_{v_1} = 0$
- $\alpha_{v_1} = v_1$
Step 2: processing $v_2$
Vertex $v_2$ has a single outgoing arc $v_2 \to v_1$. But $v_1$ has already been marked, so the algorithm does not recurse or change any pointers.
Thus:
- $v_2$ is discovered at scan time,
- no tree edge is created.
So:
$$ \tau_{v_2} = 2, \quad \pi_{v_2} = 0, \quad \alpha_{v_2} = v_2. $$
General step
For each $v_i$, when it is scanned:
- all vertices $v_{i-1}, \dots, v_1$ are already marked,
- so every outgoing arc from $v_i$ points to already-visited vertices,
- hence no arc causes a recursive discovery.
Therefore no vertex ever becomes a child of another.
Consequences for all pointers
Since no vertex is ever discovered via an arc:
$$ \pi_{v_i} = 0 \quad \text{for all } i. $$
No vertex ever gains children, so:
$$ \beta_{v_i} = 0 \quad \text{for all } i. $$
Each vertex is its own active root throughout its processing:
$$ \alpha_{v_i} = v_i \quad \text{for all } i. $$
Timestamps
Every vertex is discovered exactly at the moment it is scanned, so the timestamps again follow the scan order:
$$ \tau_{v_i} = i \quad \text{for } i=1,\dots,n. $$
Final conclusion
In both (a) and (b), the directed structure of the graph never triggers any recursive discovery, because every arc in the path points to a vertex that has already been processed by the time it is encountered.
Thus Algorithm V produces identical pointer and timestamp behavior in both cases:
$$ \boxed{ \pi_{v_i} = 0,\quad \beta_{v_i} = 0,\quad \alpha_{v_i} = v_i,\quad \tau_{v_i} = i \quad (1 \le i \le n) } $$
No other values occur.