Comparison Mode

Side-by-side: use case, requirements, complexity, strengths, weaknesses, example problems, and a clear “choose this when…”.

TarjanGraph Algos
KosarajuGraph Algos
Use caseStrongly connected components in a single DFS.Strongly connected components with two simple DFS passes.
RequirementsDiscovery times, low-link values, an explicit stack and an on-stack flag.The reversed graph and a finish-order stack from the first pass.
Time complexityO(V + E).O(V + E).
Space complexityO(V) for the arrays and stack.O(V + E) for the transposed adjacency list.
StrengthsOne pass; no reversed graph; SCCs come out in reverse topological order of the condensation.Conceptually simple; each pass is a plain DFS; components emerge in topological order of the condensation.
WeaknessesLow-link bookkeeping is easy to get wrong under interview pressure; deep recursion.Builds a second graph; two traversals instead of one.
Example problemsCritical connections (low-link variant), 2-SAT, condensation graph of a directed graph.Number of SCCs, checking if a directed graph is strongly connected, mother vertex.
Choose this whenChoose Tarjan when you want one pass, cannot afford the transposed graph, or already track low-links for bridges/articulation points.Choose Kosaraju when clarity matters more than a constant factor; two plain DFS passes are easy to explain and debug.