Loading algorithms…
A curated, interactive reference for software engineers. Study graph traversal, sorting, dynamic programming, and more — with step-by-step visualizations, complexity analysis, and pseudocode.
Showing all 22 algorithms
Find the shortest path from a source node to all others in a weighted graph with non-negative edges. The quintessential greedy graph algorithm.
O((V+E) log V)O(V+E)Explore a graph level by level from a source node. Guarantees the shortest path in unweighted graphs.
O(V+E)O(V)Explore as deep as possible before backtracking. Foundation for cycle detection, topological sort, and more.
O(V+E)O(V)Shortest paths from a source that handles negative edge weights and detects negative cycles.
O(V·E)O(V)All-pairs shortest path algorithm using dynamic programming. Works with negative weights (no negative cycles).
O(V³)O(V²)Heuristic-guided shortest path algorithm. Faster than Dijkstra's when a good heuristic is available.
O(E log V)O(V)Build a Minimum Spanning Tree by greedily adding the cheapest edges that don't form cycles.
O(E log E)O(V)Grow a Minimum Spanning Tree one vertex at a time by always picking the cheapest reachable edge.
O(E log V)O(V)Divide-and-conquer sorting that guarantees O(n log n) time. Stable, predictable, and widely used in production.
O(n log n)O(n)Partition-based sort that is extremely fast in practice despite O(n²) worst case. Pick a pivot, partition the array, recurse — average O(n log n) with great cache locality.
O(n log n) avgO(log n)Sort in-place using a max-heap. Phase 1 builds the heap; phase 2 repeatedly extracts the max. Guaranteed O(n log n) with no extra memory.
O(n log n)O(1)Repeatedly swap adjacent elements that are out of order. The simplest comparison sort — O(n²) worst case, but with an early-termination optimisation that makes it linear on already-sorted input. Stable and in-place.
O(n²)O(1)Sort integers digit by digit. Achieves linear time by exploiting digit structure instead of comparisons.
O(d·(n+k))O(n+k)Halve the search space at each step in a sorted array. The canonical O(log n) search algorithm.
O(log n)O(1)Check every element until a match is found. Works on unsorted data; baseline for search algorithm comparisons.
O(n)O(1)Cache overlapping subproblems to compute Fibonacci numbers in linear time instead of exponential.
O(n)O(n)Maximize value in a capacity-limited knapsack. A classic NP-hard problem solved efficiently with DP.
O(n·W)O(n·W)Find the longest subsequence common to two strings. Used in diff tools and bioinformatics.
O(m·n)O(m·n)Find the minimum number of coins that make up an amount. Classic unbounded knapsack variant.
O(n·amount)O(amount)A BST maintains the ordering property: left < root < right. Enables O(log n) search, insert, and delete.
O(log n) avgO(n)A self-balancing BST that maintains O(log n) height using rotations. Guarantees worst-case log n operations.
O(log n)O(n)Disjoint Set Union with path compression and union by rank. Near-constant time connectivity queries.
O(α(n)) amortizedO(n)Big-O time & space for every algorithm in this catalog
| Algorithm | Difficulty | Time Complexity | Space Complexity | Notes |
|---|---|---|---|---|
| Dijkstra's Shortest Path | Medium | O((V+E) log V) | O(V+E) | Greedy · Shortest Path |
| Breadth-First Search | Easy | O(V+E) | O(V) | Traversal · Shortest Path |
| Depth-First Search | Easy | O(V+E) | O(V) | Traversal · Recursion |
| Bellman-Ford | Medium | O(V·E) | O(V) | Shortest Path · Dynamic Programming |
| Floyd-Warshall | Medium | O(V³) | O(V²) | All-Pairs · Dynamic Programming |
| A* Search | Hard | O(E log V) | O(V) | Heuristic · Shortest Path |
| Kruskal's MST | Medium | O(E log E) | O(V) | MST · Greedy |
| Prim's MST | Medium | O(E log V) | O(V) | MST · Greedy |
| Algorithm | Difficulty | Time Complexity | Space Complexity | Notes |
|---|---|---|---|---|
| Merge Sort | Medium | O(n log n) | O(n) | Divide & Conquer · Stable |
| Quick Sort | Medium | O(n log n) avg | O(log n) | Divide & Conquer · In-Place |
| Heap Sort | Medium | O(n log n) | O(1) | Heap · In-Place |
| Bubble Sort | Easy | O(n²) | O(1) | Comparison · Stable |
| Radix Sort | Medium | O(d·(n+k)) | O(n+k) | Non-Comparison · Linear Time |
| Algorithm | Difficulty | Time Complexity | Space Complexity | Notes |
|---|---|---|---|---|
| Binary Search | Easy | O(log n) | O(1) | Divide & Conquer · Sorted Array |
| Linear Search | Easy | O(n) | O(1) | Brute Force · Unsorted |
| Algorithm | Difficulty | Time Complexity | Space Complexity | Notes |
|---|---|---|---|---|
| Fibonacci (Memoization) | Easy | O(n) | O(n) | Memoization · Overlapping Subproblems |
| 0/1 Knapsack | Hard | O(n·W) | O(n·W) | Optimization · Bottom-Up |
| Longest Common Subsequence | Medium | O(m·n) | O(m·n) | Strings · 2D DP |
| Coin Change | Medium | O(n·amount) | O(amount) | Optimization · Bottom-Up |
| Algorithm | Difficulty | Time Complexity | Space Complexity | Notes |
|---|---|---|---|---|
| Binary Search Tree | Medium | O(log n) avg | O(n) | BST · Ordered |
| AVL Tree | Hard | O(log n) | O(n) | Self-Balancing · Rotations |
| Algorithm | Difficulty | Time Complexity | Space Complexity | Notes |
|---|---|---|---|---|
| Union-Find (DSU) | Medium | O(α(n)) amortized | O(n) | Disjoint Sets · Path Compression |
More interactive visualizers are being added continuously·Press/to search,Escto clear