Report an Error

Reported page · Common Mistake

Confusing a Stack and a Queue

/mistakes/computer-science-confusing-a-stack-and-a-queue/

or drop them here

Up to 3 images or PDFs, 5 MB per file. 0 of 3 attached.

Save resource to class

Loading your classrooms…

Computer Science

Confusing a Stack and a Queue

Students remove items from a stack in the same order they were added, as if it were a queue.

Quick check

Why students make it

Both structures store items in a line, so it is easy to focus on insertion order and ignore the removal rule. The words push, pop, enqueue, and dequeue also get mixed up when students memorize names instead of behavior.

The rule done right

A stack is LIFO, so the last item added is the first item removed. A queue is FIFO, so the first item added is the first item removed.