Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the discovery time array for all vertices.
DSA C#
int[] disc = new int[n]; for (int i = 0; i < n; i++) { disc[i] = [1]; }
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing discovery time to 0 causes confusion with valid discovery times.
Using int.MaxValue is unnecessary and less clear.
✗ Incorrect
Discovery times are initialized to -1 to indicate unvisited vertices.
2fill in blank
mediumComplete the code to update the low time of the current vertex after visiting a child.
DSA C#
low[u] = Math.Min(low[u], [1]);Attempts:
3 left
💡 Hint
Common Mistakes
Using disc[v] instead of low[v] misses back edges reachable from descendants.
Using disc[u] or time is incorrect for this update.
✗ Incorrect
Low time of u is updated with the low time of its child v.
3fill in blank
hardFix the error in the condition to check if the current vertex is an articulation point (not root).
DSA C#
if (parent[u] != -1 && low[v] >= [1]) { ap[u] = true; }
Attempts:
3 left
💡 Hint
Common Mistakes
Using low[u] instead of disc[u] breaks the articulation point logic.
Comparing with disc[v] or time is incorrect.
✗ Incorrect
We compare low[v] with disc[u] to check if v or its descendants can reach an ancestor of u.
4fill in blank
hardFill both blanks to complete the DFS call and update the child count for root articulation point check.
DSA C#
for (int v = 0; v < graph[u].Count; v++) { int w = graph[u][v]; if (disc[w] == -1) { parent[w] = u; [1]++; DFS(w, [2]); } }
Attempts:
3 left
💡 Hint
Common Mistakes
Passing time instead of u as parent in DFS call.
Incrementing wrong variable instead of children.
✗ Incorrect
We increment children count and call DFS on child vertex w with current vertex u.
5fill in blank
hardFill all three blanks to complete the root articulation point condition and mark it.
DSA C#
if (parent[u] == -1 && [1] > [2]) { [3][u] = true; }
Attempts:
3 left
💡 Hint
Common Mistakes
Using time instead of 1 in comparison.
Marking wrong array or variable.
✗ Incorrect
Root vertex u is an articulation point if it has more than one child in DFS tree.
