Loop Lab: for vs while
Step both loops side by side — see when a counted for fits, and when a condition-driven while is better.
Swapping two variables
Watch values copy between memory boxes as a temp-variable swap runs line by line — and see why the naive approach loses data.
Totalling an array
Keep a running total in a labeled box while a for loop adds each array element.
Counting occurrences
Scan the list and watch the count box increase every time the target appears.
Finding max & min
Track the largest and smallest values seen so far in labeled boxes as the loop runs.
Printing a 2D array
Visit cells of a grid — whole matrix, one row, or one column — and watch values print in order.
Totalling a 2D array
Sum the whole grid, or build a list of totals — one per row, or one per column.
Counting in a 2D array
Count a target across the whole grid, or build a list of counts — one per row, or one per column.
Max & min in a 2D array
Find extremes across the whole grid, or build max/min lists — one pair per row, or per column.
Linear search
Scan left to right and compare each element until the target is found — or the list ends.
Parallel arrays
Keep related lists aligned by index — linear search a name, then read the mark at the same position.
Binary search
Halve the search space each step and watch low, mid and high pointers converge.
Bubble sort
Compare neighbours, swap, and stop early with a swapped flag when a pass changes nothing.
Selection sort
Find the minimum of the unsorted region each pass and swap it into place on the left.
Static arrays
Fixed capacity block — insert and delete by shifting neighbours. When full, insert is refused.
Dynamic arrays
Same contiguous block — when full, allocate a larger block, copy values over, then keep inserting.
Stacks
Push and pop values, then watch call stack frames push and pop as nested functions run.
Recursive factorial
Watch factorial(n) push frames onto the call stack, hit the base case, then unwind with return values.
Recursive Fibonacci
Grow the fib(n) call tree and spot the same subproblems computed again and again.
Queues
Enqueue at the back, dequeue from the front — first in, first out, like a waiting line.
Linked lists
Compare singly, doubly, and circular lists — then search, insert, and remove nodes.
Binary search trees
Insert, search, and delete nodes, then walk the tree with inorder, preorder, and postorder traversals.
Sets
Unordered unique elements — membership, add/remove, union, intersection, difference, and subsets.
Hash tables
Hash keys into buckets, resolve collisions with chaining, and watch the load factor — the engine behind dict and set.
Infrared door sensor
Watch distance readings stream from an IR sensor to a microprocessor that opens the door within 1 m.
Fetch–execute cycle
Step through fetch and execute while PC, IR, MAR, MDR, CU, accumulator, ALU, and RAM light up.
How a page is fetched
Type a URL, ask DNS for an IP address, request files from the web server, then watch the browser render the page.
How HTTPS works
Check a digital certificate, then watch the order stay locked while it crosses the network.
Interrupt handling
See how priority and the interrupt queue let the processor keep running for a printer, then handle a keyboard.
How sound is sampled
Compare a smooth wave with sample rectangles. Change the sampling frequency and bit depth, then play the stored sound.
Run-length encoding
Turn repeated letters, and flat rows of a picture, into a count and a symbol.
Two-layer network
Follow a forward pass and backpropagation, then watch the error curve fall as the weights change.
Convolutional neural network
See a digit travel through CNN layers to scores 0–9. Hover a layer, such as convolution, for the step in detail.
Clustering
Group students by quiz and project scores, with no pass or fail label to learn from.
Learning a route
A robot tries three routes and learns which one is on time most often.
Fit a line to house prices
Fit a straight line to six house prices, then compare your line with the best-fit line.
Classify the new student
Predict whether Ari passes from the labelled students who are nearest on quiz and project scores.
Turn practice into a pass probability
Turn practice questions into a probability of passing, then move the threshold that makes the decision.
Built for understanding, not memorising
Whether the topic is a loop in Python or a machine in automata theory, fuzzy mental models get clearer when you can watch the idea unfold.
Step at your own pace
Advance one step at a time, step back, or press play. The active step is always highlighted so you never lose your place.
See state change
Variables, arrays, stacks — and later automata, gates, and other models — are drawn as labeled boxes that update as each step runs.
Plain-language explanations
Every step comes with a short explanation of what happened and why — including the traps students commonly hit.
Build intuition before the exam — or the code
- Replay any step as many times as you need
- See how variables, structures, and models change
- Keyboard shortcuts for fast stepping
Project it, share a link, done
- No accounts, installs or plugins — just a URL
- Each simulation is a single page that works offline
- Designed to be readable on a classroom projector