Stacks and queues sound like the sort of thing you should already understand.
We stack plates.
We queue for coffee.
Easy.
Then Computer Science arrives, adds LIFO, FIFO, push, pop, enqueue and dequeue, and suddenly we're apparently studying an entirely different subject.
The good news is that stacks and queues are actually very simple once you understand one difference:
A stack removes the newest item first.
A queue removes the oldest item first.
That's basically the whole argument.
What Is a Stack in Computer Science?
A stack is a data structure that follows:
LIFO — Last In, First Out.
Imagine a stack of plates.
You put a plate on top.
Then another.
Then another.
When someone needs a plate, they normally take the top one first.
The last plate added is therefore the first plate removed.
That's LIFO.
Stack example
Imagine we add three books:
Book A → Book B → Book C
Book C was added last.
So Book C comes off first.
Then Book B.
Then Book A.
Computer Science has simply given your pile of books a formal name.
What Is a Queue in Computer Science?
A queue follows:
FIFO — First In, First Out.
This one works like an actual queue of people.
Imagine three people arrive:
A → B → C
A arrived first.
So A should be served first.
Then B.
Then C.
If C suddenly gets served first, that's no longer a queue.
That's just going to annoy everyone.

Stack vs Queue: What’s the Difference?
The key difference is the order in which data leaves.
STACK
Last item added → first item removed.
LIFO
Think: stack of plates.
QUEUE
First item added → first item removed.
FIFO
Think: people waiting in line.
If you remember those two examples, you've already understood the most important difference between a stack and a queue.
What Is a Stack Data Structure Used For?
Stacks are useful when the most recent item needs to be dealt with first.
A brilliant everyday computing example is Undo.
Imagine you're editing something and make three changes:
Change A → Change B → Change C
Then you press Undo.
Which change should disappear first?
Change C.
The most recent action is removed first.
That's stack behaviour.
Stacks are also used in areas such as function calls and expression processing.
What Is a Queue Data Structure Used For?
Queues are useful when things should be processed in the order they arrive.
A good example is a printer queue.
Imagine three documents are sent to a printer:
Document A → Document B → Document C
Normally, Document A is processed first because it arrived first.
Then B.
Then C.
First In, First Out.
Printers, for once, are behaving logically.
Push and Pop in a Stack
Stacks have two important operations:
Push = add an item to the top of the stack.
Pop = remove an item from the top.
Imagine our stack contains:
A → B → C
If we push D, D becomes the newest item.
If we then pop, D is the first item removed.
You don't need to make this complicated.
Push = put on.
Pop = take off.
Enqueue and Dequeue in a Queue
Queues have their own unnecessarily impressive vocabulary.
Enqueue = add an item to the back of the queue.
Dequeue = remove an item from the front.
Imagine:
A → B → C
If D arrives, it joins the back:
A → B → C → D
When the next item is processed, A leaves first.
Again:
First In, First Out.
The terminology sounds complicated.
The actual idea is basically standing in line.
LIFO vs FIFO
If you're revising data structures, these are the two acronyms worth remembering.
LIFO
Last In, First Out
Used by a stack.
Think of piling books or plates on top of each other.
FIFO
First In, First Out
Used by a queue.
Think of people waiting to be served.
One tiny letter changes the entire structure.
Computer Science does enjoy doing that.
Stack vs Queue for Computer Science Students
If you're asked to compare stacks and queues, don't just define them separately.
Make the difference explicit.
For example:
A stack uses LIFO, so the last item added is the first item removed, whereas a queue uses FIFO, so the first item added is the first item removed.
That's the comparison.
You should also be comfortable recognising:
- LIFO and FIFO
- Push and pop
- Enqueue and dequeue
- The order items are added and removed
- Appropriate real-world examples
- Situations where each data structure could be useful
The Easiest Way to Remember Stack vs Queue
Forget the acronyms for a second.
Picture two things:
A pile of plates.
A queue at a café.
With the plates, you take the newest one from the top.
STACK = newest out first.
At the café, the person who arrived first expects to be served first.
QUEUE = oldest out first.
Now add the terminology back:
Stack = LIFO.
Queue = FIFO.
Much easier.
The Stack vs Queue poster puts both data structures side by side, making it useful for Computer Science revision, data structures lessons, programming classrooms and visual learning.
[Download the free Stack vs Queue poster →]
Quick Recap
STACK
LIFO — Last In, First Out.
Add with push.
Remove with pop.
Think stack of plates.
QUEUE
FIFO — First In, First Out.
Add with enqueue.
Remove with dequeue.
Think people waiting in line.
So next time LIFO and FIFO appear in a Computer Science question, don't panic.
Just remember:
Plates don't queue. People don't stack.
And you're basically there.

