Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the discovery time vector with -1 for all vertices.
DSA Rust
let mut disc = vec![-1; [1]];
Attempts:
3 left
💡 Hint
Common Mistakes
Using graph[0].len() which gives the number of neighbors of the first vertex, not total vertices.
Using graph.capacity() which is unrelated to vertex count.
✗ Incorrect
The discovery time vector should have one entry per vertex, so its length must be the number of vertices, which is graph.len().
2fill in blank
mediumComplete the code to update the low time of u after visiting neighbor v.
DSA Rust
low[u] = std::cmp::min(low[u], [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using disc[v] instead of low[v], which ignores back edges reachable from v.
Using disc[u] which does not update low[u] correctly.
✗ Incorrect
The low[u] value is updated to the minimum of its current value and low[v], which represents the earliest visited vertex reachable from v.
3fill in blank
hardFix the error in the condition to check if u is an articulation point when u is not root.
DSA Rust
if parent[u] != -1 && low[v] >= [1] {
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing low[v] with low[u] which is incorrect for articulation point check.
Using disc[v] which is unrelated here.
✗ Incorrect
The condition low[v] >= disc[u] means that v or its descendants cannot reach an ancestor of u, so u is an articulation point.
4fill in blank
hardFill both blanks to correctly implement the DFS call and update the child count.
DSA Rust
for &v in &graph[u] { if disc[v] == -1 { parent[v] = u; [1](v, time, disc, low, parent, ap, graph); children += 1; } }
Attempts:
3 left
💡 Hint
Common Mistakes
Using bfs which is breadth-first search, not suitable here.
Using undefined function names like visit or search.
✗ Incorrect
The DFS function is called recursively on vertex v to explore its subtree.
5fill in blank
hardFill all three blanks to correctly check and mark the root as an articulation point.
DSA Rust
if parent[u] == -1 && [1] > [2] { ap[u] = [3]; }
Attempts:
3 left
💡 Hint
Common Mistakes
Using false instead of true for ap[u].
Comparing children with 0 instead of 1.
✗ Incorrect
If u is root (parent[u] == -1) and has more than one child, it is an articulation point, so ap[u] is set to true.
