O(n) · visualised

Algorithm & data-structure visualizer

Watch classic algorithms and data structures run step by step. Pick one to start.

Sorting algorithms

Watch arrays sort themselves, step by step.

Bubble sortBubble sort repeatedly swaps adjacent out-of-order elements, letting the largest "bubble" to the end each pass.Insertion sortInsertion sort builds the sorted array one item at a time, inserting each new element into its place among the earlier ones.Selection sortSelection sort repeatedly finds the smallest remaining element and moves it to the front.Merge sortMerge sort splits the array in half, sorts each half, then merges the two sorted halves together.Quick sortQuick sort picks a pivot, partitions the array around it, then sorts the two sides.Heap sortHeap sort builds a max-heap, then repeatedly moves the largest element to the end.Shell sortShell sort is insertion sort that first compares far-apart elements, shrinking the gap each round.Cocktail sortCocktail sort is bubble sort that sweeps both ways — bubbling the largest up and the smallest down each round.Comb sortComb sort is bubble sort that compares elements a large gap apart, shrinking the gap toward 1.Gnome sortGnome sort steps forward while order is correct and swaps backward when it isn't.Odd-even sortOdd-even sort compares fixed pairs — first the odd-indexed pairs, then the even ones — repeating until none are out of order.Pancake sortPancake sort sorts using only prefix flips: bring the largest value to the front, then flip it down to its place.Cycle sortCycle sort places each value directly into its final spot, making the theoretical minimum number of writes.Stooge sortStooge sort is a recursive curiosity: sort the first 2/3, then the last 2/3, then the first 2/3 again.Counting sortCounting sort doesn't compare elements — it tallies how many of each value there are, then writes them back out in order. Linear time when the value range is small.Radix sortRadix sort sorts numbers one digit at a time, least-significant first, using a stable bucket pass for each digit. No comparisons needed.

Searching

Find a value in an array.

Selection

Find the k-th smallest value.

Data structures

How data is stored, added, and removed.

Tree algorithms

Walk a tree, node by node.

Graph algorithms

Traversing nodes and edges.

BFSBreadth-first search explores a graph level by level using a FIFO queue.DFSDepth-first search explores as far as possible down each branch before backtracking, using a stack.Dijkstra (shortest path)Dijkstra finds the shortest path from a start node by always expanding the closest unvisited node — here edge cost is the distance between nodes.Prim's MSTPrim grows a minimum spanning tree from a start node, always adding the cheapest edge that reaches a new node.Kruskal's MSTKruskal builds a minimum spanning tree by adding edges from cheapest to most expensive, skipping any that would form a cycle.Borůvka's MSTBorůvka builds a minimum spanning tree in rounds: every component grabs its own cheapest outgoing edge at once, so the forest merges quickly in parallel.Bellman-FordBellman-Ford finds shortest paths by relaxing every edge V-1 times — slower than Dijkstra, but it handles negative edge weights.Topological sortA topological sort lines up the vertices of a directed acyclic graph so every edge points forward — a valid order to do tasks that depend on each other.Floyd-WarshallFloyd-Warshall finds the shortest distance between every pair of vertices at once, by repeatedly asking whether routing through one more vertex is shorter.Connected componentsConnected components are the separate "islands" of a graph — maximal groups of vertices reachable from one another. A flood-fill colours each one.Bipartite checkA graph is bipartite if its vertices split into two groups with every edge crossing between them — checked by 2-colouring with BFS.Cycle detectionCycle detection asks whether an undirected graph contains a loop — DFS finds one the moment it meets a back edge to an earlier vertex.

Grid pathfinding

Route through a maze of walls.

Dynamic programming

Fill a table, reuse subproblems.