DSA Explorer
QuicksortMerge SortBubble SortInsertion SortSelection SortHeap SortCounting SortRadix SortBucket SortShell SortTim SortCocktail Shaker SortComb SortGnome SortPancake SortPatience SortCycle SortStrand SortWiggle Sort (Wave Sort)Bead Sort (Gravity Sort)Binary Insertion SortBitonic SortBogo Sort (Stupid Sort)Stooge SortOdd-Even Sort (Brick Sort)Pigeonhole SortIntro Sort (Introspective Sort)Tree Sort (BST Sort)Dutch National Flag (3-Way Partitioning)
Binary SearchLinear SearchJump SearchInterpolation SearchExponential SearchTernary SearchFibonacci SearchQuick Select (k-th Smallest)Median of Medians (Deterministic Select)Hill climbingSimulated AnnealingTabu SearchBinary Tree DFS SearchSentinel Linear SearchDouble Linear SearchTernary Search (Unimodal Function)Search in 2D Matrix
Binary Search Tree (BST)StackQueueHash Table (Hash Map)Heap (Priority Queue)Linked ListTrie (Prefix Tree)Binary TreeTrie (Prefix Tree)Floyd's Cycle Detection (Tortoise and Hare)Merge Two Sorted Linked ListsCheck if Linked List is PalindromeFind Middle of Linked ListBalanced Parentheses (Valid Parentheses)Next Greater ElementInfix to Postfix ConversionMin Stack (O(1) getMin)Largest Rectangle in HistogramDaily Temperatures (Monotonic Stack)Evaluate Reverse Polish NotationInfix Expression Evaluation (Two Stacks)Min Heap & Max HeapSliding Window MaximumTrapping Rain WaterRotate Matrix 90 DegreesSpiral Matrix TraversalSet Matrix ZeroesHash Table with ChainingOpen Addressing (Linear Probing)Double HashingCuckoo Hashing
Depth-First Search (DFS)Breadth-First Search (BFS)Dijkstra's AlgorithmFloyd-Warshall AlgorithmKruskal's AlgorithmPrim's AlgorithmTopological SortA* Pathfinding AlgorithmKahn's Algorithm (Topological Sort)Ford-Fulkerson Max FlowEulerian Path/CircuitBipartite Graph CheckBorůvka's Algorithm (MST)Bidirectional DijkstraPageRank AlgorithmBellman-Ford AlgorithmTarjan's Strongly Connected ComponentsArticulation Points (Cut Vertices)Find Bridges (Cut Edges)Articulation Points (Cut Vertices)Finding Bridges (Cut Edges)
0/1 Knapsack ProblemLongest Common Subsequence (LCS)Edit Distance (Levenshtein Distance)Longest Increasing Subsequence (LIS)Coin Change ProblemFibonacci Sequence (DP)Matrix Chain MultiplicationRod Cutting ProblemPalindrome Partitioning (Min Cuts)Subset Sum ProblemWord Break ProblemLongest Palindromic SubsequenceMaximal Square in MatrixInterleaving StringEgg Drop ProblemUnique Paths in GridCoin Change II (Count Ways)Decode WaysWildcard Pattern MatchingRegular Expression MatchingDistinct SubsequencesMaximum Product SubarrayHouse RobberClimbing StairsPartition Equal Subset SumKadane's Algorithm (Maximum Subarray)
A* Search AlgorithmConvex Hull (Graham Scan)Line Segment IntersectionCaesar CipherVigenère CipherRSA EncryptionHuffman CompressionRun-Length Encoding (RLE)Lempel-Ziv-Welch (LZW)Canny Edge DetectionGaussian Blur FilterSobel Edge FilterHarris Corner DetectionHistogram EqualizationMedian FilterLaplacian FilterMorphological ErosionMorphological DilationImage Thresholding (Otsu's Method)Conway's Game of LifeLangton's AntRule 30 Cellular AutomatonFast Fourier Transform (FFT)Butterworth FilterSpectrogram (STFT)
Knuth-Morris-Pratt (KMP) AlgorithmRabin-Karp AlgorithmBoyer-Moore AlgorithmAho-Corasick AlgorithmManacher's AlgorithmSuffix ArraySuffix Tree (Ukkonen's Algorithm)Trie for String MatchingEdit Distance for StringsLCS for String MatchingHamming DistanceJaro-Winkler DistanceDamerau-Levenshtein DistanceBitap Algorithm (Shift-Or, Baeza-Yates-Gonnet)Rolling Hash (Rabin-Karp Hash)Manacher's AlgorithmZ AlgorithmLevenshtein Distance

Tarjan's Strongly Connected Components

Graph
O(V + E) time, O(V) space
Advanced

Algorithm to find all strongly connected components (SCCs) in a directed graph in linear time. A strongly connected component is a maximal set of vertices where every vertex is reachable from every other vertex. Invented by Robert Tarjan in 1972, it uses a single DFS pass with low-link values to identify SCCs.

Prerequisites:
Directed Graphs
DFS
Stack

Visualization

Interactive visualization for Tarjan's Strongly Connected Components

Tarjan's SCC Algorithm

01234567

• Time: O(V + E)

• Single DFS pass

• Finds all strongly connected components

Interactive visualization with step-by-step execution

Implementation

Language:
1class TarjanSCC {
2  private index = 0;
3  private stack: number[] = [];
4  private indices: Map<number, number> = new Map();
5  private lowLinks: Map<number, number> = new Map();
6  private onStack: Set<number> = new Set();
7  private sccs: number[][] = [];
8  
9  findSCCs(graph: Map<number, number[]>): number[][] {
10    for (const vertex of graph.keys()) {
11      if (!this.indices.has(vertex)) {
12        this.strongConnect(vertex, graph);
13      }
14    }
15    return this.sccs;
16  }
17  
18  private strongConnect(v: number, graph: Map<number, number[]>): void {
19    this.indices.set(v, this.index);
20    this.lowLinks.set(v, this.index);
21    this.index++;
22    this.stack.push(v);
23    this.onStack.add(v);
24    
25    const neighbors = graph.get(v) || [];
26    for (const w of neighbors) {
27      if (!this.indices.has(w)) {
28        this.strongConnect(w, graph);
29        this.lowLinks.set(v, Math.min(this.lowLinks.get(v)!, this.lowLinks.get(w)!));
30      } else if (this.onStack.has(w)) {
31        this.lowLinks.set(v, Math.min(this.lowLinks.get(v)!, this.indices.get(w)!));
32      }
33    }
34    
35    if (this.lowLinks.get(v) === this.indices.get(v)) {
36      const scc: number[] = [];
37      let w: number;
38      do {
39        w = this.stack.pop()!;
40        this.onStack.delete(w);
41        scc.push(w);
42      } while (w !== v);
43      this.sccs.push(scc);
44    }
45  }
46}

Deep Dive

Theoretical Foundation

Tarjan's algorithm maintains a stack of vertices and assigns each vertex an index (discovery time) and low-link value (smallest index reachable). When a vertex's low-link equals its index, it's an SCC root. All vertices on stack above it form one SCC. The algorithm combines DFS with stack to detect back edges efficiently.

Complexity

Time

Best

O(V + E)

Average

O(V + E)

Worst

O(V + E)

Space

Required

O(V)

Applications

Industry Use

1

Compiler optimization (call graph analysis)

2

Social network analysis (mutually connected groups)

3

Web page ranking and link analysis

4

Deadlock detection in database systems

5

Module dependency analysis in software

6

Circuit design verification and optimization

7

Game theory (finding stable coalitions)

Use Cases

Social networks
Compiler optimization
Deadlock detection

Related Algorithms

Depth-First Search (DFS)

Graph traversal exploring as deep as possible before backtracking. DFS is a fundamental algorithm that uses a stack (either implicitly through recursion or explicitly) to explore graph vertices. It's essential for cycle detection, topological sorting, and pathfinding problems.

Graph

Breadth-First Search (BFS)

Level-by-level graph traversal guaranteeing shortest paths in unweighted graphs. BFS uses a queue to explore vertices level by level, making it optimal for finding shortest paths and solving problems that require exploring nearest neighbors first.

Graph

Dijkstra's Algorithm

Finds shortest path from source to all vertices in weighted graph with non-negative edges. Uses greedy approach with priority queue.

Graph

Floyd-Warshall Algorithm

Floyd-Warshall is an all-pairs shortest path algorithm that finds shortest distances between every pair of vertices in a weighted graph. Unlike Dijkstra (single-source), it computes shortest paths from all vertices to all other vertices simultaneously. The algorithm can handle negative edge weights but not negative cycles. Developed independently by Robert Floyd, Bernard Roy, and Stephen Warshall in the early 1960s.

Graph
DSA Explorer

Master Data Structures and Algorithms through interactive visualizations and detailed explanations. Our platform helps you understand complex concepts with clear examples and real-world applications.

Quick Links

  • About DSA Explorer
  • All Algorithms
  • Data Structures
  • Contact Support

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Code of Conduct

Stay Updated

Subscribe to our newsletter for the latest algorithm explanations, coding challenges, and platform updates.

We respect your privacy. Unsubscribe at any time.

© 2026 Momin Studio. All rights reserved.

SitemapAccessibility
v1.0.0