Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the discovery time slice for all vertices.
DSA Go
discovery := make([]int, [1]) for i := range discovery { discovery[i] = -1 }
Attempts:
3 left
💡 Hint
Common Mistakes
Using capacity instead of length for slice initialization.
Initializing with zero length causing index errors.
✗ Incorrect
We initialize the discovery slice with the length of the graph to store discovery times for each vertex.
2fill in blank
mediumComplete the code to update the low time of the current vertex after visiting a neighbor.
DSA Go
if discovery[neighbor] != -1 { low[current] = min(low[current], [1]) }
Attempts:
3 left
💡 Hint
Common Mistakes
Using low[neighbor] instead of discovery[neighbor].
Using low[current] which does not update low time correctly.
✗ Incorrect
We update low[current] with the discovery time of the neighbor if it was already visited.
3fill in blank
hardFix the error in the articulation point check condition for non-root vertices.
DSA Go
if parent != -1 && low[neighbor] >= [1] { articulation[current] = true }
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing with discovery[neighbor] instead of discovery[current].
Using low[current] which is incorrect for this condition.
✗ Incorrect
We compare low[neighbor] with discovery[current] to check if current is an articulation point.
4fill in blank
hardFill both blanks to correctly implement the DFS call and update the child count.
DSA Go
for _, neighbor := range graph[current] { if discovery[neighbor] == -1 { parent[neighbor] = current [1](neighbor) childCount++ } }
Attempts:
3 left
💡 Hint
Common Mistakes
Using BFS or other function names instead of dfs.
Not incrementing childCount causing wrong articulation point detection.
✗ Incorrect
We call dfs recursively on the neighbor and increment childCount for articulation point logic.
5fill in blank
hardFill all three blanks to correctly update low time and mark articulation points for root vertex.
DSA Go
if parent[current] == -1 && [1] > 1 { articulation[current] = [2] } low[current] = min(low[current], [3])
Attempts:
3 left
💡 Hint
Common Mistakes
Marking root as articulation point incorrectly when childCount <= 1.
Using false instead of true to mark articulation point.
Updating low time with wrong value.
✗ Incorrect
Root vertex is articulation point if it has more than one child; low time updated with discovery time of neighbor.
