Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the discovery time array for all vertices.
DSA Javascript
const disc = new Array(V).fill([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of -1 causes confusion between visited and unvisited nodes.
Using null or Infinity is not standard for discovery times.
✗ Incorrect
We initialize discovery times with -1 to indicate unvisited vertices.
2fill in blank
mediumComplete the code to update the low time of u after visiting v.
DSA Javascript
low[u] = Math.min(low[u], [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using disc[v] instead of low[v] misses back edges in v's subtree.
Using disc[u] or v is incorrect for updating low[u].
✗ Incorrect
We update low[u] with the minimum low[v] to track earliest reachable ancestor.
3fill in blank
hardFix the error in the condition to check if u is an articulation point when u is root.
DSA Javascript
if (parent[u] === -1 && [1] > 1) { ap[u] = true; }
Attempts:
3 left
💡 Hint
Common Mistakes
Using low[u] or disc[u] instead of children count.
Checking visited[u] is irrelevant here.
✗ Incorrect
Root is articulation point if it has more than one child in DFS tree.
4fill in blank
hardFill both blanks to check if u is an articulation point when u is not root.
DSA Javascript
if (parent[u] !== -1 && [1] >= [2]) { ap[u] = true; }
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping disc[u] and disc[v] or low[u] and low[v].
Using disc[v] instead of low[v] causes wrong checks.
✗ Incorrect
If low[v] >= disc[u], u is articulation point because v cannot reach above u.
5fill in blank
hardFill all three blanks to complete the DFS function header and recursive call.
DSA Javascript
function dfs([1], [2], [3]) { // DFS logic here }
Attempts:
3 left
💡 Hint
Common Mistakes
Using visited instead of graph as parameter.
Missing parent parameter causes incorrect articulation point detection.
✗ Incorrect
DFS needs current node u, parent node, and graph to traverse.
