Explore

Browse the AlgoLens catalog

Search starter algorithms, filter by category, and jump directly into a trace-driven lesson.

Backtracking
Intermediate

N-Queens

Places one queen per row while avoiding column and diagonal conflicts.

Avg O(n!)
Space O(n)
Open visualization
Backtracking
Beginner

Rat in a Maze

Explores valid moves until it reaches the exit or needs to backtrack.

Avg O(4^(n^2))
Space O(n^2)
Open visualization
Backtracking
Advanced

Sudoku Solver

Fills empty cells with digits that satisfy row, column, and box constraints.

Avg O(9^(n^2))
Space O(n^2)
Open visualization
Backtracking
Advanced

Hamiltonian Cycle

Builds a cycle that visits every vertex exactly once and returns to the start.

Avg O(V!)
Space O(V)
Open visualization
Backtracking
Intermediate

Graph Coloring

Assigns colors so adjacent vertices never share the same color.

Avg O(m^V)
Space O(V)
Open visualization
Backtracking
Advanced

Knights Tour

Moves the knight so every square is visited exactly once.

Avg O(8^(n^2))
Space O(n^2)
Open visualization
Branch and Bound
Advanced

Traveling Salesman Problem (TSP)

Searches for the cheapest Hamiltonian cycle while pruning branches whose lower bound is already too expensive.

Avg O(n!)
Space O(n)
Open visualization
Branch and Bound
Advanced

0/1 Knapsack

Explores include/exclude decisions while pruning branches whose upper bound cannot beat the best value.

Avg O(2^n)
Space O(n)
Open visualization
Branch and Bound
Advanced

Job Assignment Problem

Assigns one unique job to each worker while pruning assignments that already cost too much.

Avg O(n!)
Space O(n)
Open visualization
Brute Force
Beginner

Linear Search

Scans each element one by one until a match is found.

Avg O(n)
Space O(1)
Open visualization
Brute Force
Beginner

Selection Sort

Selects the minimum remaining element and swaps it into place.

Avg O(n^2)
Space O(1)
Open visualization
Sorting
Beginner

Bubble Sort

Repeatedly compares adjacent values and bubbles larger items toward the right edge.

Avg O(n^2)
Space O(1)
Open visualization
Brute Force
Beginner

Naive String Matching

Tries every possible pattern alignment against the text.

Avg O(nm)
Space O(1)
Open visualization
Divide and Conquer
Advanced

Strassens Matrix Multiplication

Multiplies matrices by reducing the number of recursive subproducts.

Avg O(n^log2(7))
Space O(n^2)
Open visualization
Divide and Conquer
Advanced

Closest Pair of Points

Recursively splits points by x-coordinate and checks a narrow strip around the midpoint.

Avg O(n log n)
Space O(n)
Open visualization
Dynamic Programming
Beginner

Fibonacci (DP)

Builds Fibonacci values bottom-up in a table.

Avg O(n)
Space O(n)
Open visualization
Dynamic Programming
Intermediate

Longest Common Subsequence (LCS)

Builds a matrix of best subsequence lengths for every prefix pair.

Avg O(nm)
Space O(nm)
Open visualization
Dynamic Programming
Intermediate

Longest Increasing Subsequence (LIS)

Tracks the best increasing subsequence ending at each position.

Avg O(n^2)
Space O(n)
Open visualization
Dynamic Programming
Advanced

Matrix Chain Multiplication

Finds the cheapest way to parenthesize a matrix product chain.

Avg O(n^3)
Space O(n^2)
Open visualization
Dynamic Programming
Intermediate

0/1 Knapsack (DP)

Fills a value table over items and capacities.

Avg O(nW)
Space O(nW)
Open visualization
Dynamic Programming
Intermediate

Coin Change

Builds the minimum coins needed for every amount up to the target.

Avg O(nA)
Space O(A)
Open visualization
Dynamic Programming
Intermediate

Edit Distance

Measures the minimum insertions, deletions, and substitutions to transform one string into another.

Avg O(nm)
Space O(nm)
Open visualization
Dynamic Programming
Intermediate

Rod Cutting

Builds the best obtainable revenue for every rod length up to the target.

Avg O(n^2)
Space O(n)
Open visualization
Greedy
Beginner

Activity Selection

Chooses the next activity that finishes earliest among the compatible options.

Avg O(n log n)
Space O(1)
Open visualization
Greedy
Advanced

Huffman Coding

Builds an optimal prefix code by repeatedly merging the two lightest nodes.

Avg O(n log n)
Space O(n)
Open visualization
Greedy
Intermediate

Kruskals Minimum Spanning Tree

Adds the lightest edge that does not create a cycle.

Avg O(E log E)
Space O(V)
Open visualization
Greedy
Intermediate

Prims Minimum Spanning Tree

Grows one tree by repeatedly taking the cheapest edge leaving the current tree.

Avg O(E log V)
Space O(V)
Open visualization
Greedy
Beginner

Fractional Knapsack

Takes items by decreasing value density, allowing fractional picks when capacity runs out.

Avg O(n log n)
Space O(1)
Open visualization
Simple Recursive
Beginner

Factorial

Multiplies n by factorial(n - 1) until the base case is reached.

Avg O(n)
Space O(n)
Open visualization
Simple Recursive
Beginner

Fibonacci (recursive)

Expands into two recursive calls until the small base cases are reached.

Avg O(2^n)
Space O(n)
Open visualization
Simple Recursive
Intermediate

Tower of Hanoi

Moves a stack of disks using one spare rod and the recursive three-step pattern.

Avg O(2^n)
Space O(n)
Open visualization
Simple Recursive
Beginner

Power Calculation

Raises a base to an exponent using recursive exponentiation by squaring.

Avg O(log n)
Space O(log n)
Open visualization
Uncategorized
Beginner

Euclidean Algorithm (GCD)

Repeatedly replaces the larger problem with the remainder until it becomes zero.

Avg O(log min(a, b))
Space O(1)
Open visualization
Uncategorized
Beginner

Sieve of Eratosthenes

Marks multiples of each prime to eliminate composite numbers in bulk.

Avg O(n log log n)
Space O(n)
Open visualization
Uncategorized
Beginner

Kadanes Algorithm

Keeps the best subarray ending at the current position and the best overall answer.

Avg O(n)
Space O(1)
Open visualization
Uncategorized
Advanced

FloydWarshall Algorithm

Computes all-pairs shortest paths by gradually allowing more intermediate vertices.

Avg O(n^3)
Space O(n^2)
Open visualization
Uncategorized
Advanced

BellmanFord Algorithm

Relaxes every edge repeatedly to support negative weights.

Avg O(VE)
Space O(V)
Open visualization
Sorting
Beginner

Insertion Sort

Builds a sorted prefix by inserting each value into its proper place.

Avg O(n^2)
Space O(1)
Open visualization
Sorting
Intermediate

Merge Sort

Recursively splits the array, sorts halves, and merges them back together.

Avg O(n log n)
Space O(n)
Open visualization
Sorting
Intermediate

Quick Sort

Partitions around a pivot so smaller values move left and larger values move right.

Avg O(n log n)
Space O(log n)
Open visualization
Searching
Beginner

Binary Search

Searches a sorted array by repeatedly halving the active interval.

Avg O(log n)
Space O(1)
Open visualization
Graph
Beginner

Breadth-First Search

Explores the graph level by level using a queue.

Avg O(V + E)
Space O(V)
Open visualization
Graph
Intermediate

Depth-First Search

Explores one branch deeply before backtracking.

Avg O(V + E)
Space O(V)
Open visualization
Graph
Advanced

Dijkstra

Computes shortest paths in graphs with non-negative edge weights.

Avg O((V + E) log V)
Space O(V)
Open visualization