algos-lab algorithms, visual

1. Sorting race

Same shuffled array, four algorithms, side by side. Bar height = value, color = state.

bubble0
insertion0
quick0
merge0

2. Pathfinding

Click to draw walls. Drag the start (green) and goal (red). Compare BFS, Dijkstra, A*.

visited
path length

3. Binary search

O(log n). Each step halves the window. Pointers: lo, mid, hi.

steps
found at

4. Graph traversal — BFS vs DFS

Click any node to set start. BFS visits by level; DFS dives.

visit order

5. Hash table

Type a key. Hash with `h = (h*31 + char) mod m`. Watch collisions chain or probe.

load factor0.00
worst chain0

6. Backtracking — N-Queens

Place `n` queens; none attack. Red cells flash on conflict before the algorithm prunes.

tries0
solutions found0

7. DP — Fibonacci recursion tree

Naive recursion is exponential. Memoization turns repeated subproblems (red) into table lookups.

calls
result

8. 0/1 Knapsack DP table

Each cell `dp[i][w]` is the best value using items `0..i` with capacity `w`. Trace back to recover the chosen items.

items chosen
total value
weight used

9. Big-O comparison

Same input size `n`, very different growth rates. Log y-axis toggle.

O(1)
O(log n)
O(n)
O(n log n)
O(n²)
O(2ⁿ)