algo.viz

algorithms · animated · interactive — dogfetus.no

Algorithm Visualizer

Interactive animations for sorting, pathfinding, and tree algorithms. Click any card or use the tabs above.

Bubble Sort
Sorting
O(n²) time · O(1) space
Insertion Sort
Sorting
O(n²) · O(1) space
Merge Sort
Sorting
O(n log n) · O(n) space
Quick Sort
Sorting
O(n log n) avg · O(log n)
Heap Sort
Sorting
O(n log n) · O(1) space
BFS
Pathfinding
O(V+E) · guaranteed shortest
DFS
Pathfinding
O(V+E) · not optimal
Dijkstra
Pathfinding
O((V+E) log V) · optimal
A*
Pathfinding
O(E) heuristic · optimal
BST
Tree
O(log n) avg · O(h) space

Bubble Sort

O(n²) time O(1) space Comparison

Repeatedly steps through the list, compares adjacent elements and swaps them if they're in the wrong order. The largest values "bubble up" to the end each pass.

Speed
Comparisons: 0   Swaps: 0

Insertion Sort

O(n²) worst O(1) space Comparison

Builds a sorted portion one element at a time by taking each new element and inserting it into its correct position in the already-sorted left portion.

Speed
Comparisons: 0   Swaps: 0

Merge Sort

O(n log n) O(n) space Divide & Conquer

Recursively divides the array in half, sorts each half, then merges them back together. Guaranteed O(n log n) but requires extra memory for merging.

Speed
Comparisons: 0   Writes: 0

Quick Sort

O(n log n) avg O(log n) stack Divide & Conquer

Picks a pivot element and partitions the array around it so elements less than pivot go left, greater go right. Recursively sorts each partition in place.

Speed
Comparisons: 0   Swaps: 0

Heap Sort

O(n log n) O(1) space Heap-based

Builds a max-heap from the array, then repeatedly extracts the maximum to build the sorted result. Combines good worst-case guarantees with in-place operation.

Speed
Comparisons: 0   Swaps: 0

Breadth-First Search

O(V+E) O(V) queue Graph Search

Explores all neighbors at the current depth before moving deeper. Guarantees the shortest path in an unweighted graph. Uses a queue (FIFO).

Speed
Start
End
Wall
Visited
Frontier
Path

Depth-First Search

O(V+E) O(V) stack Graph Search

Dives as deep as possible along each branch before backtracking. Does not guarantee shortest path. Uses a stack (LIFO) — naturally recursive.

Speed
Start
End
Wall
Visited
Path

Dijkstra's Algorithm

O((V+E) log V) O(V) Weighted Graph

Finds the shortest path in a weighted graph. Uses a priority queue to always expand the currently cheapest node. On an unweighted grid it behaves like BFS.

Speed
Start
End
Wall
Visited
Frontier
Path

A* Search

O(E) best case O(V) Heuristic Search

Extends Dijkstra with a heuristic function h(n) estimating distance to the goal. f(n) = g(n) + h(n). With Manhattan distance heuristic it's optimally efficient on grids.

Speed
Start
End
Wall
Visited
Frontier
Path

Binary Search Tree

O(log n) avg O(n) Tree Structure

Each node has at most two children. Left subtree contains only nodes with values less than the parent; right subtree only greater values. Supports O(log n) search, insert, and delete on average.

Traversal: