All Algorithms
48 interactive · 49 total
Binary Search
LiveFind an element in a sorted array by halving the search space each step.
Linear Search
LiveScan every element until the target is found.
Jump Search
LiveJump ahead by √n steps then do linear search within the block.
Bubble Sort
LiveRepeatedly swap adjacent elements that are out of order.
Selection Sort
LiveFind the minimum element and place it at the front, repeat.
Insertion Sort
LiveBuild a sorted array one element at a time by inserting into position.
Merge Sort
LiveDivide in half, sort each half recursively, merge back.
Quick Sort
LivePick a pivot, partition around it, recursively sort partitions.
Heap Sort
LiveBuild a max-heap, then extract elements one by one.
Radix Sort
LiveSort integers digit by digit from least to most significant.
Counting Sort
LiveCount occurrences of each value, then reconstruct sorted output.
Breadth-First Search
LiveExplore all neighbors at the current depth before going deeper.
Depth-First Search
LiveExplore as deep as possible before backtracking.
Dijkstra's Algorithm
LiveFind shortest paths from a source node using a priority queue.
A* Search
LiveDijkstra + a heuristic to guide search toward the goal.
Bellman-Ford
LiveSingle-source shortest paths that handles negative edge weights.
Floyd-Warshall
LiveFind shortest paths between all pairs of nodes.
Kruskal's Algorithm
LiveBuild MST by greedily adding cheapest edges that don't form cycles.
Topological Sort
LiveLinear ordering of vertices in a directed acyclic graph.
BST Insert & Search
LiveInsert and search nodes in a Binary Search Tree.
AVL Tree
SoonSelf-balancing BST that keeps height difference ≤ 1 via rotations.
Fibonacci (DP)
LiveCompute Fibonacci numbers efficiently using memoization or tabulation.
0/1 Knapsack
LiveMaximize value of items in a knapsack with weight limit.
Longest Common Subsequence
LiveFind the longest subsequence present in both sequences.
Coin Change
LiveFind minimum coins needed to make a target amount.
Huffman Coding
LiveLossless compression by assigning shorter codes to frequent characters.
KMP String Search
LiveFind pattern in text in O(n+m) using a failure function.
Sieve of Eratosthenes
LiveFind all primes up to N by eliminating multiples.
Euclidean GCD
LiveCompute greatest common divisor using repeated division.
Hash Table
LiveKey-value store with O(1) average lookup using a hash function.
Bloom Filter
LiveSpace-efficient probabilistic set membership test with false positives.
Shell Sort
LiveGeneralization of insertion sort that compares elements far apart, then narrows the gap.
Tim Sort
LiveHybrid of merge sort and insertion sort. Used in Python, Java, and V8.
Bucket Sort
LiveDistribute elements into buckets, sort each bucket, then concatenate.
Cycle Sort
LiveMinimizes the number of writes to memory — optimal for write-expensive media.
Prim's MST
LiveGrow a minimum spanning tree by greedily adding the cheapest edge to the frontier.
Floyd's Cycle Detection
LiveDetect cycles in a sequence using two pointers at different speeds.
Union-Find (Disjoint Set)
LiveTrack which elements belong to the same group with near-O(1) union and find.
Segment Tree
LiveTree for fast range queries (sum, min, max) with O(log n) update.
Fenwick Tree (BIT)
LiveCompact structure for prefix sum queries and point updates in O(log n).
Trie (Prefix Tree)
LiveTree where each node represents a character. Enables O(m) prefix lookups.
Edit Distance (Levenshtein)
LiveMinimum insertions, deletions, and substitutions to transform one string to another.
Longest Increasing Subsequence
LiveFind the longest strictly increasing subsequence in O(n log n).
Kadane's Algorithm
LiveFind the contiguous subarray with the largest sum in O(n).
Matrix Chain Multiplication
LiveFind the optimal parenthesization of matrix products to minimize operations.
Rabin-Karp
LiveUse a rolling hash to find pattern in text in expected O(n+m).
Z-Algorithm
LiveBuild a Z-array to find all pattern occurrences in O(n+m).
Two Sum
LiveFind two numbers in an array that add to a target in O(n).
Sliding Window Maximum
LiveFind the maximum in every window of size k in O(n) using a monotonic deque.