A stack works last in, first out — the last thing added is the first thing removed, like taking a plate off the top of a pile. A queue works first in, first out — whoever joined first gets served first, just like a line outside a shop. Picture a stack of plates versus a queue at the bakery and the order of removal tells you which is which.
The core difference
A stack removes the most recently added item first; a queue removes items in the order they arrived.
- stack — a pile of things placed one on top of another, or the same idea in computing where the last item added is the first removed: each function call pushes a new frame onto the stack.
- queue — a line of people or items waiting their turn, served in the order they arrived: the print job sat in the queue behind three other documents.
How to tell them apart
Both words describe things waiting to be dealt with, but the order is opposite. With a stack, picture a stack of plates: you always take the top one off first, so the last plate placed down is the first one removed. With a queue, picture people queuing at a bakery: whoever joined the line first gets served first, and nobody can jump ahead of someone who arrived earlier.
The words carry the same logic outside computing too. Stacking chairs or sandbags means piling them up, with the most recent addition on top and easiest to reach. Queuing for tickets or joining a queue means taking your place in line and waiting your turn in order.