Algorithm visualizer
See what an algorithm really does, step by step: your Python program is run by real Python in your browser and you see the list as bars, every comparison and every swap, the indexes (i, j, mid…), the call stack and the recursion tree. Searching, recursion and sorting, with the Java version alongside. It works on your phone too.
How to use it
- Pick an example: linear or binary search (iterative, or recursive with a helper that takes the bounds), factorial, power, Fibonacci, the towers of Hanoi, bubble, selection, insertion, merge sort or quicksort.
- Change the data (the list, the value you look for, the
n…) or press Random. If you like, press Edit the code and write your own program. - Press Step to go line by line or Run to watch it play. Coral shows what is compared; violet, what is written. Under each bar, the indexes pointing at it.
- In recursion, the stack shows the calls that are waiting and the tree shows every call made and what each one returned.
How it works
The program is run by Pyodide (CPython 3.14 compiled to WebAssembly), the same Python as the playground, and followed line by line with sys.settrace. Nothing is simulated: the counters come from the comparisons Python really makes. To know who is compared with whom, the numbers in the lists you write in the program are ordinary Python numbers that also remember who they are.
The rules it follows
- Every
<,<=,>,>=,==or!=involving a list item counts as a comparison, including the onessorted(),min()orinmake inside. - Every list position that changes counts as a write, including adding with
append. A swap is two writes. - It stops at 4,000 steps and 150 nested calls, so an infinite loop or a recursion with no base case cannot freeze the page.
input()is not available: write the data in the program.
For the exam
FP1 asks what a recursive function returns, how many calls it makes or how the range shrinks in binary search; FP2, what Arrays.sort and binarySearch do inside. The challenge below asks you to beat Python to it: how many comparisons, how many calls or what the list looks like after one lap, and checks it by running the program.

IC2 theory mock exam — first midterm, second midterm or the full exam, with your real mark and a review of every mistake (as if you were in the exam room)