PPractick

DSA interview question

Articulation Points in a Graph

Hard · Data structures · Topics: graph, dfs, articulation point

The problem

In a road network, some intersections are single points of failure: if an intersection closes, part of the city is cut off. These vertices are articulation points (cut vertices). Tarjan's DFS with discovery times and low-links finds them all in one pass:

Example: 5 vertices, edges 0-1, 1-2, 2-0, 1-3, 3-4 → [1, 3].

Function signature

vector<int> articulationPoints(int V, const vector<pair<int, int>>& edges);  // sorted, or {-1} if none

Test cases

Input (V, edges)OutputExplanation
(5, [[0,1],[1,2],[2,0],[1,3],[3,4]])[1, 3]1 separates {3, 4}; 3 separates {4}
(4, [[0,1],[1,2],[2,3]])[1, 2]Interior vertices of a path
(5, [[0,1],[0,2],[0,3],[0,4]])[0]The centre of a star
(3, [[0,1],[1,2],[2,0]])[-1]A cycle has none
(2, [[0,1]])[-1]

(Confirm: the graph is undirected and simple; it may be disconnected; return [−1] when there are no articulation points.)

How interviewers phrase it

Clarifying questions to ask

  1. Can the graph be disconnected? (Yes, so treat every DFS tree separately.)
  2. What output format? (Sorted, or [−1] when there are none.)
  3. Parallel edges? (Assume a simple graph.)

Follow-ups to expect

  1. "Why ≥ here but > for bridges?"
  2. "Why is the root special?"
  3. "Why count DFS children, not neighbours?"
  4. "What are biconnected components?"
  5. "Complexity?"

Practise questions like this with a real engineer

On Practick another engineer interviews you live for 60 minutes on a question from this bank. They have the full interviewer guide beside the call: the expected answer to every follow-up, hints to give if you stall, and a scoring rubric. You get the model solution once the session settles. It is free: interview someone for an hour and you have earned your own.

Book a free mock interview

Related questions

All 474 dsa interview questions

DSA mock interviews · System design interview questions · Free mock interview practice · Browse interviewers · Sign in