Skip to interview prep
Apexed

4. What is the difference between a stack and a queue? Give a use for each.

EasyData structures & algorithms

Technical
Show model answer

A stack is last-in, first-out (LIFO): push and pop at the same end. It powers function call stacks, undo, and depth-first search.

A queue is first-in, first-out (FIFO): enqueue at the back, dequeue at the front. It powers breadth-first search, job scheduling and buffering between producers and consumers.

What is the difference between a stack and a queue? Give a use for each. — Software engineering interview question — Apexed