Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the discovery time array with -1 for all vertices.
DSA Typescript
const disc: number[] = new Array(V).fill([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of -1 causes confusion with valid discovery times.
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 Typescript
low[u] = Math.min(low[u], [1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using disc[v] instead of low[v] misses back edges.
Using disc[u] or low[u] does not update correctly.
✗ 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 Typescript
if (parent[u] === -1 && [1] > 1) { ap[u] = true; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using low[u] or disc[u] instead of children count.
Checking visited[u] is irrelevant here.
✗ Incorrect
Root u 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 Typescript
if (parent[u] !== -1 && [1] >= [2]) { ap[u] = true; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping low[v] and disc[u] in condition.
Using low[u] or disc[v] incorrectly.
✗ Incorrect
If low[v] >= disc[u], u is an articulation point for non-root nodes.
5fill in blank
hardFill all three blanks to complete the DFS function signature and initial call.
DSA Typescript
function dfs([1], [2], [3]) { // DFS logic here } dfs(0, -1, time);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using visited instead of parent or time in parameters.
Incorrect order of parameters.
✗ Incorrect
DFS function takes current node u, its parent, and current time.