Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the discovery time array for all vertices.
DSA Java
int[] disc = new int[[1]];Attempts:
3 left
💡 Hint
Common Mistakes
Using the number of edges instead of vertices.
Using zero instead of the array size.
✗ Incorrect
The discovery time array should be initialized with the number of vertices V.
2fill in blank
mediumComplete the code to mark a vertex as visited.
DSA Java
visited[[1]] = true;Attempts:
3 left
💡 Hint
Common Mistakes
Marking the parent vertex instead of the current vertex.
Using time or discovery time as index.
✗ Incorrect
The vertex u should be marked as visited when it is first discovered.
3fill in blank
hardFix the error in updating the low time of vertex u.
DSA Java
low[u] = Math.min(low[u], [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using discovery time instead of low time.
Using time or discovery time of u incorrectly.
✗ Incorrect
The low time of u should be updated with the low time of v to track back edges.
4fill in blank
hardFill both blanks to check if u is an articulation point when v is not visited.
DSA Java
if (disc[u] == 0 && low[v] >= [1]) { ap[u] = true; } if (disc[u] > 0 && low[v] >= [2]) { ap[u] = true; }
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing discovery and low times incorrectly.
Using time variable instead of disc or low arrays.
✗ Incorrect
For root vertex, check if low[v] >= disc[u]. For other vertices, check low[v] >= low[u].
5fill in blank
hardFill all three blanks to implement the DFS call for articulation points.
DSA Java
for (int v : graph[[1]]) { if (!visited[v]) { parent[v] = [2]; dfs(v, [3], graph, visited, disc, low, parent, ap); } }
Attempts:
3 left
💡 Hint
Common Mistakes
Using v instead of u for adjacency.
Setting parent incorrectly.
Passing wrong parameters to dfs.
✗ Incorrect
Iterate neighbors of u, set parent[v] = u, and call dfs with v and current time.
