Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the adjacency list for the graph.
DSA C++
vector<int> adj[[1]];Attempts:
3 left
💡 Hint
Common Mistakes
Using 'edges' instead of 'n' for adjacency list size.
Using 'visited' which is unrelated here.
✗ Incorrect
The adjacency list is declared with size 'n', the number of vertices.
2fill in blank
mediumComplete the code to initialize the discovery time of a node.
DSA C++
disc[u] = [1]++;Attempts:
3 left
💡 Hint
Common Mistakes
Using 'time' which may be a reserved word or undefined.
Using 'count' or 'index' which are unrelated.
✗ Incorrect
The discovery time is set using the 'timer' variable which increments after assignment.
3fill in blank
hardFix the error in the condition to check if a node is an articulation point for root.
DSA C++
if (parent == -1 && children > [1]) articulation[u] = true;
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or 1 which incorrectly marks root nodes with fewer children.
Using 3 which is too strict.
✗ Incorrect
A root node is an articulation point if it has more than 1 child, so children > 1 means 2 or more children.
4fill in blank
hardFill both blanks to update the low time after visiting a neighbor.
DSA C++
low[u] = min(low[u], [1][[2]]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using parent or visited arrays which are unrelated here.
Swapping disc and low arrays incorrectly.
✗ Incorrect
We update low[u] with the minimum of low[u] and disc[v] to track earliest reachable ancestor.
5fill in blank
hardFill all three blanks to complete the DFS function signature and recursive call.
DSA C++
void dfs(int [1], int [2], vector<int> adj[], vector<bool> &[3]) { visited[u] = true; // rest of DFS code }
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'timer' as a parameter which is unrelated here.
Mixing parameter order or names.
✗ Incorrect
The DFS function takes current node 'u', its 'parent', adjacency list, and visited array by reference.
