{Agorithm}

All Algorithms

48 interactive · 49 total

Binary Search

Live

Find an element in a sorted array by halving the search space each step.

SearchingbeginnerO(log n)

Linear Search

Live

Scan every element until the target is found.

SearchingbeginnerO(n)

Jump Search

Live

Jump ahead by √n steps then do linear search within the block.

SearchingintermediateO(√n)

Bubble Sort

Live

Repeatedly swap adjacent elements that are out of order.

SortingbeginnerO(n²)

Selection Sort

Live

Find the minimum element and place it at the front, repeat.

SortingbeginnerO(n²)

Insertion Sort

Live

Build a sorted array one element at a time by inserting into position.

SortingbeginnerO(n²)

Merge Sort

Live

Divide in half, sort each half recursively, merge back.

SortingintermediateO(n log n)

Quick Sort

Live

Pick a pivot, partition around it, recursively sort partitions.

SortingintermediateO(n log n)

Heap Sort

Live

Build a max-heap, then extract elements one by one.

SortingintermediateO(n log n)

Radix Sort

Live

Sort integers digit by digit from least to most significant.

SortingintermediateO(nk)

Counting Sort

Live

Count occurrences of each value, then reconstruct sorted output.

SortingintermediateO(n+k)

Breadth-First Search

Live

Explore all neighbors at the current depth before going deeper.

GraphbeginnerO(V+E)

Depth-First Search

Live

Explore as deep as possible before backtracking.

GraphbeginnerO(V+E)

Dijkstra's Algorithm

Live

Find shortest paths from a source node using a priority queue.

GraphintermediateO((V+E) log V)

A* Search

Live

Dijkstra + a heuristic to guide search toward the goal.

GraphadvancedO(b^d)

Bellman-Ford

Live

Single-source shortest paths that handles negative edge weights.

GraphintermediateO(VE)

Floyd-Warshall

Live

Find shortest paths between all pairs of nodes.

GraphintermediateO(V³)

Kruskal's Algorithm

Live

Build MST by greedily adding cheapest edges that don't form cycles.

GraphintermediateO(E log E)

Topological Sort

Live

Linear ordering of vertices in a directed acyclic graph.

GraphintermediateO(V+E)

BST Insert & Search

Live

Insert and search nodes in a Binary Search Tree.

TreebeginnerO(log n)

AVL Tree

Soon

Self-balancing BST that keeps height difference ≤ 1 via rotations.

TreeadvancedO(log n)

Fibonacci (DP)

Live

Compute Fibonacci numbers efficiently using memoization or tabulation.

DPbeginnerO(n)

0/1 Knapsack

Live

Maximize value of items in a knapsack with weight limit.

DPintermediateO(nW)

Longest Common Subsequence

Live

Find the longest subsequence present in both sequences.

DPintermediateO(mn)

Coin Change

Live

Find minimum coins needed to make a target amount.

DPintermediateO(n·amount)

Huffman Coding

Live

Lossless compression by assigning shorter codes to frequent characters.

GreedyintermediateO(n log n)

KMP String Search

Live

Find pattern in text in O(n+m) using a failure function.

StringadvancedO(n+m)

Sieve of Eratosthenes

Live

Find all primes up to N by eliminating multiples.

MathbeginnerO(n log log n)

Euclidean GCD

Live

Compute greatest common divisor using repeated division.

MathbeginnerO(log min(a,b))

Hash Table

Live

Key-value store with O(1) average lookup using a hash function.

Data StructureintermediateO(1)

Bloom Filter

Live

Space-efficient probabilistic set membership test with false positives.

Data StructureadvancedO(k)

Shell Sort

Live

Generalization of insertion sort that compares elements far apart, then narrows the gap.

SortingintermediateO(n log² n)

Tim Sort

Live

Hybrid of merge sort and insertion sort. Used in Python, Java, and V8.

SortingadvancedO(n log n)

Bucket Sort

Live

Distribute elements into buckets, sort each bucket, then concatenate.

SortingintermediateO(n+k)

Cycle Sort

Live

Minimizes the number of writes to memory — optimal for write-expensive media.

SortingadvancedO(n²)

Prim's MST

Live

Grow a minimum spanning tree by greedily adding the cheapest edge to the frontier.

GraphintermediateO((V+E) log V)

Floyd's Cycle Detection

Live

Detect cycles in a sequence using two pointers at different speeds.

GraphintermediateO(n)

Union-Find (Disjoint Set)

Live

Track which elements belong to the same group with near-O(1) union and find.

Data StructureintermediateO(α(n))

Segment Tree

Live

Tree for fast range queries (sum, min, max) with O(log n) update.

Data StructureadvancedO(log n)

Fenwick Tree (BIT)

Live

Compact structure for prefix sum queries and point updates in O(log n).

Data StructureadvancedO(log n)

Trie (Prefix Tree)

Live

Tree where each node represents a character. Enables O(m) prefix lookups.

Data StructureintermediateO(m)

Edit Distance (Levenshtein)

Live

Minimum insertions, deletions, and substitutions to transform one string to another.

DPintermediateO(mn)

Longest Increasing Subsequence

Live

Find the longest strictly increasing subsequence in O(n log n).

DPintermediateO(n log n)

Kadane's Algorithm

Live

Find the contiguous subarray with the largest sum in O(n).

DPbeginnerO(n)

Matrix Chain Multiplication

Live

Find the optimal parenthesization of matrix products to minimize operations.

DPadvancedO(n³)

Rabin-Karp

Live

Use a rolling hash to find pattern in text in expected O(n+m).

StringintermediateO(n+m)

Z-Algorithm

Live

Build a Z-array to find all pattern occurrences in O(n+m).

StringintermediateO(n+m)

Two Sum

Live

Find two numbers in an array that add to a target in O(n).

SearchingbeginnerO(n)

Sliding Window Maximum

Live

Find the maximum in every window of size k in O(n) using a monotonic deque.

SearchingintermediateO(n)