What information entered the process?
Labs / Computer Science
Stack & Queue Playground
A stack and a queue receive the exact same stream of values, so you can watch two rules for ordering play out side by side. Push and pop the vertical stack, enqueue and dequeue the horizontal queue, or just leave auto-burst running — then click either structure to yank an element off it.
Labs / Computer Science / Stack & Queue Playground
Stack & Queue Playground
A stack and a queue receive the exact same stream of values, so you can watch two rules for ordering play out side by side. Push and pop the vertical stack, enqueue and dequeue the horizontal queue, or just leave auto-burst running — then click either structure to yank an element off it.
Why it matters
Why explore this?
Computer science turns clear rules into reliable processes. This model lets you step through those rules and see how each decision changes the result.
Explore
Try the model
Investigate
Questions to test
Predict first, try it in the model, then use what you observe to answer.
What to try
- Push 1, 2, 3 and enqueue 1, 2, 3. Now remove one from each — which value leaves the stack, and which leaves the queue?
- The stack's top pointer and the queue's front pointer never point at the same element for long. When do they finally agree?
- Fill both to the brim. Why does the stack always hand back the newest value while the queue hands back the oldest?
- Turn on auto-burst and slow the speed down. Can you predict the next value to leave each structure before it slides out?
- If you only ever pushed and popped, could a stack ever behave like a queue — and what would that cost you?
Explain
Make sense of what happened
Trace the process one step at a time. Name the rule used at each important step, then explain why the final result follows from those rules.
Check
Before you leave
Which rule changed it?
Why did the process produce this result?
If you can answer all three using evidence from the model, you understand the main idea. If not, return to Explore and change one setting at a time.