Back home
Interactive learning

Algorithm visual lab

Control each operation, change inputs, and watch invariants develop across sorting, searching, stacks, queues, trees, and graphs.

Sorting

Bubble, selection, and insertion sort with comparisons, writes, and adjustable playback.

34
12
47
8
29
41
19

Initial unsorted array

Step 1/33 · 0 comparisons · 0 writes

Bubble sort

Adjacent inversions disappear; after each pass, the largest remaining value is fixed.

Selection sort

The prefix is final; each pass selects its next minimum from the suffix.

Insertion sort

The prefix is sorted; the current key is inserted without disturbing that invariant.

Searching

Compare a sequential scan with logarithmic range elimination.

Binary search automatically sorts custom input because sorted order is its core precondition.

4
0
9
1
13
2
18
3
25
4
31
5
42
6
57
7
68
8
74
9

25 < 42; discard indices 0–4

Step 1/4 · 1 comparison · active range [0, 9]

Stacks & queues

Perform operations and see LIFO and FIFO boundaries move.

Top / push & pop ↓
12
24
36

Ready for an operation

size = 3

Tree traversals

Switch between preorder, inorder, postorder, and level order.

Change the order and watch when each node is processed.

1234567
4251637visit order

Process node 4 · 1 of 7

Graph traversals

Inspect how BFS uses a queue while DFS uses a stack.

Both start at A; neighbour order is alphabetical.

ABCDEF

Visited

A

Queue · front → rear

B · C

Visit A; add B, C to the queue