Visualizer Library

Every algorithm, animated

57 algorithms with live variable state, call stacks and step control. Pick one, load a template — or write your own and let the engine trace it.

Trace your own code
57 of 57

Bubble Sort

Sorting

Repeatedly steps through the list, compares adjacent elements and swaps them if in wrong order.

time O(n²) · space O(1)Visualize

Selection Sort

Sorting

Divides the input list into sorted and unsorted portions, repeatedly selecting the minimum element from unsorted portion.

time O(n^2) · space O(1)Visualize

Insertion Sort

Sorting

Builds the final sorted array one element at a time by inserting each element into its correct position.

time O(n^2) · space O(1)Visualize

Merge Sort

Sorting

A divide-and-conquer algorithm that recursively splits the array into halves, sorts each half, then merges the sorted halves.

time O(n log n) · space O(n)Visualize

Quick Sort

Sorting

A highly efficient divide-and-conquer algorithm that selects a pivot and partitions the array around it.

time O(n log n) · space O(log n)Visualize

Heap Sort

Sorting

Builds a binary max-heap from the array, then repeatedly extracts the maximum element and places it at the end.

time O(n log n) · space O(1)Visualize

Binary Search

Searching

Finds the position of a target value within a sorted array by repeatedly dividing the search interval in half.

time O(log n) · space O(1)Visualize

Linear Search

Searching

Sequentially checks each element of a list until a match is found or the whole list is searched.

time O(n) · space O(1)Visualize

Dijkstra's Algorithm

Graph

Finds the shortest paths from a source node to all other nodes in a weighted graph with non-negative edge weights.

time O(V + E log V) · space O(V)Visualize

Breadth-First Search

Graph

Traverses or searches a graph level by level, exploring all neighbors at the current depth before moving deeper.

time O(V + E) · space O(V)Visualize

Depth-First Search

Graph

Explores a graph by going as deep as possible along each branch before backtracking.

time O(V + E) · space O(V)Visualize

Bellman-Ford Algorithm

Graph

Finds the shortest paths from a source node to all other nodes, handling negative edge weights and detecting negative cycles.

time O(V * E) · space O(V)Visualize

Kruskal's Algorithm

Graph

Finds a minimum spanning tree (MST) by sorting all edges by weight and adding the smallest edges that do not form a cycle.

time O(E log E) · space O(V)Visualize

Prim's Algorithm

Graph

Finds an MST by growing a single tree from a starting vertex, always adding the cheapest edge connecting a new vertex.

time O(E log V) · space O(V)Visualize

Topological Sort

Graph

Orders the vertices of a DAG linearly such that for every directed edge u->v, vertex u comes before v.

time O(V + E) · space O(V)Visualize

Floyd-Warshall Algorithm

Graph

Finds shortest paths between all pairs of vertices in a weighted graph using dynamic programming.

time O(V^3) · space O(V^2)Visualize

Fibonacci Sequence

Dynamic Programming

Computes the nth Fibonacci number using memoization.

time O(n) · space O(n)Visualize

0/1 Knapsack

Dynamic Programming

Determines max value obtainable by selecting items with given weights/values within capacity.

time O(n*W) · space O(n*W)Visualize

Longest Common Subsequence

Dynamic Programming

Finds the longest subsequence common to two sequences.

time O(m*n) · space O(m*n)Visualize

Longest Increasing Subsequence

Dynamic Programming

Finds length of the longest strictly increasing subsequence.

time O(n log n) · space O(n)Visualize

Inorder Traversal

Tree

Traverses a binary tree: left subtree, root, right subtree (LNR).

time O(n) · space O(h)Visualize

Preorder Traversal

Tree

Traverses a binary tree: root, left subtree, right subtree (NLR).

time O(n) · space O(h)Visualize

Lowest Common Ancestor

Tree

Finds the deepest node that has both target nodes as descendants.

time O(n) · space O(h)Visualize

Binary Search Tree

Tree

Maintains sorted data with O(log n) avg search, insert, and delete.

time O(log n) · space O(n)Visualize

Activity Selection

Greedy

Selects max non-overlapping activities by choosing earliest finishing ones.

time O(n log n) · space O(1)Visualize

Huffman Coding

Greedy

Creates optimal variable-length prefix codes for lossless compression.

time O(n log n) · space O(n)Visualize

Coin Change (Greedy)

Greedy

Finds min coins for target amount using largest denominations first.

time O(n log n) · space O(1)Visualize

N-Queens

Recursion

Places N queens on N x N board so none threaten each other.

time O(n!) · space O(n)Visualize

Subset Sum

Recursion

Generates all subsets or determines if subset sums to target.

time O(2^n) · space O(n)Visualize

Tower of Hanoi

Recursion

Moves N disks using auxiliary peg. Larger disk never on smaller.

time O(2^n) · space O(n)Visualize

Radix Sort

Sorting

Sorts integers digit by digit without comparing elements directly.

time O(nk) · space O(n+k)Visualize

Counting Sort

Sorting

Counts occurrences of each value to build a sorted output.

time O(n+k) · space O(n+k)Visualize

Ternary Search

Searching

Searches a unimodal function by repeatedly discarding two-thirds of the range.

time O(log n) · space O(1)Visualize

A* Search

Graph

Finds a shortest path using the cost so far plus a heuristic estimate.

time O(E log V) · space O(V)Visualize

Union-Find

Data Structures

Maintains connected components with near-constant union and find operations.

time O(α(n)) · space O(n)Visualize

Knuth–Morris–Pratt

String

Finds a pattern in text without rechecking characters after a mismatch.

time O(n+m) · space O(m)Visualize

Trie

Data Structures

Stores strings character by character for fast prefix queries.

time O(L) · space O(nL)Visualize

Sieve of Eratosthenes

Math

Generates all prime numbers up to a limit by marking composite multiples.

time O(n log log n) · space O(n)Visualize

Euclidean GCD

Math

Computes the greatest common divisor using repeated remainders.

time O(log n) · space O(1)Visualize

Fast Exponentiation

Math

Computes powers in logarithmic time by repeatedly squaring the base.

time O(log n) · space O(1)Visualize

XOR Tricks

Bit Manipulation

Uses XOR identities to cancel duplicates and isolate unique values.

time O(n) · space O(1)Visualize

Sliding Window

Data Structures

Maintains a moving range to solve contiguous subarray and substring problems.

time O(n) · space O(k)Visualize

Array Operations

Data Structures

Index, insert, delete, and traverse contiguous memory.

time Depends on operation · space Depends on representationVisualize

Linked List

Data Structures

Follow and update pointers through singly and doubly linked nodes.

time Depends on operation · space Depends on representationVisualize

Hash Table

Data Structures

Map keys to buckets and resolve collisions with probing or chaining.

time Depends on operation · space Depends on representationVisualize

Fenwick Tree

Data Structures

Answer prefix and range sums with compact binary indexed updates.

time Depends on operation · space Depends on representationVisualize

Segment Tree

Data Structures

Combine interval summaries to answer range queries and point updates.

time Depends on operation · space Depends on representationVisualize

Cycle Finding

Math

Detect a repeated state using Floyd's tortoise-and-hare technique.

time Depends on operation · space Depends on representationVisualize

Suffix Tree

String

Index every suffix of a string for fast substring and repeat queries.

time Depends on operation · space Depends on representationVisualize

Suffix Array

String

Sort suffix starting positions and use LCP values for string queries.

time Depends on operation · space Depends on representationVisualize

Convex Hull

Math

Wrap a set of points with the smallest convex polygon using monotone chain.

time Depends on operation · space Depends on representationVisualize

Maximum Flow

Graph

Push capacity through a network until no augmenting path remains.

time Depends on operation · space Depends on representationVisualize

Bipartite Matching

Graph

Pair vertices across two partitions through augmenting paths.

time Depends on operation · space Depends on representationVisualize

Minimum Vertex Cover

Graph

Choose the smallest set of vertices touching every edge in a bipartite graph.

time Depends on operation · space Depends on representationVisualize

Steiner Tree

Graph

Connect required terminals with optional helper vertices at minimum cost.

time Depends on operation · space Depends on representationVisualize

Traveling Salesperson

Graph

Find a minimum-cost tour that visits every location exactly once.

time Depends on operation · space Depends on representationVisualize

NP-Complete Reductions

Recursion

Understand how one hard decision problem can be transformed into another.

time Depends on operation · space Depends on representationVisualize