Algorithms Visualization
Four small Unity tools that animate classic computer-science algorithms step by step: three ways to solve a Sudoku, four sorts racing the same bars into order, five ways to search a grid for a path, and two sieves hunting primes.
Built in 2022 in high school · Windows & Android
Understanding algorithms by watching them think
This project started from a simple frustration: reading an algorithm's pseudocode never made it click the way watching it actually run did. So instead of just implementing a handful of textbook algorithms for a school assignment, I built a small Unity app around them — one screen per topic, where every comparison, swap, guess, and backtrack gets drawn on screen the moment it happens, at whatever speed I set.
The result is four independent visualizers behind a shared menu, each built around the same idea: pick an algorithm from a dropdown, tune the speed and the input size with a couple of sliders, and press go. It's a UI simple enough that it runs just as well with a mouse on a PC as with a thumb on an Android phone.
Three solvers, from brute force to genuinely clever
The same 9x9 grid, solved three different ways side by side. Every guess, deduction, and backtrack gets its own color on the board, so the gap between blind guessing and actual logic is something you can watch rather than take on faith.
- Brute Force
Tries the first legal digit in each empty cell, in order, and backtracks the moment a cell runs out of legal options. Simple to write, but it can end up testing thousands of dead-end guesses on a hard puzzle.
- Best Candidate
Same backtracking search, but always guesses the emptiest cell first — the one with the fewest legal digits left. That one change in ordering prunes dead ends dramatically earlier.
- Crook's Algorithm
Adds a layer of pure logic on top of Best Candidate: it fills in every cell a human could deduce without guessing — hidden singles, cells that are the only spot left for a digit in their row, column or box, and naked subsets — and only falls back to guessing for whatever logic alone can't finish.
Four sorts racing the same bars into order
Every number becomes a bar, height mapped to value, redrawn on every comparison and swap. Running the same shuffled array through all four algorithms in turn makes the difference in how they attack the problem obvious instead of theoretical.
- Bubble Sort
Repeatedly walks the array, swapping adjacent bars that are out of order, so the largest values "bubble" to the end one pass at a time. O(n²), and the simplest of the four to follow.
- Selection Sort
Scans the unsorted remainder for its smallest bar and swaps it into place at the front, one position at a time. O(n²), same as Bubble Sort but with far fewer actual swaps.
- Insertion Sort
Builds a sorted prefix one bar at a time, sliding each new value backward until it lands in the right spot. O(n²) worst case, but close to instant on an array that's already nearly sorted.
- Quick Sort
Picks a pivot bar, partitions the rest into a smaller and a larger pile around it, then recurses on each pile. O(n log n) on average, and visibly the fastest of the four past a handful of bars.
Five ways to search a grid for the shortest way through
A grid of tiles stands in for a maze: place a start and an end, drop some walls, and watch each algorithm expand outward tile by tile until it reaches the target — or gives up. Speed and grid size are both adjustable, which makes it easy to see which algorithms waste time exploring in the wrong direction.
- BFS
Expands outward one full ring of neighboring tiles at a time. Always finds the shortest path on an unweighted grid, but explores evenly in every direction, even straight away from the target.
- DFS
Commits to a single direction as far as it can go before backtracking. Finds a path, not necessarily the shortest one — useful mainly as a contrast to the other four.
- Dijkstra
Like BFS, but weighted: always expands whichever known tile is cheapest to reach next, which starts to matter the moment tiles stop costing the same amount to cross.
- Greedy Best-First Search
Always steps toward whichever tile looks closest to the target in a straight line. Fast when the way is clear, but easily fooled into long detours around a wall.
- A*
Combines Dijkstra's guaranteed shortest path with Greedy's straight-line heuristic, so it explores toward the target without giving up correctness along the way.
Two sieves hunting primes on the same grid
A grid of numbers from 1 up to a chosen limit, crossed out one composite at a time until only primes stay highlighted. The two sieves reach the exact same answer, but the crossing-out pattern each leaves behind looks nothing alike.
- Sieve of Eratosthenes
Starting from 2, marks every multiple of each newly found prime as composite, skipping straight past numbers already eliminated. The classic sieve, and the more intuitive one to watch.
- Sieve of Sundaram
Eliminates numbers of the form i + j + 2ij, then doubles whatever survives and adds one to recover the odd primes. Same result as Eratosthenes, but a noticeably stranger pattern on screen.
- C#
- Unity
- Windows
- Android