What is the difference between a stack and a queue, and when would you choose one over the other?

technical-conceptual · Junior level · software-engineering

What the interviewer is really asking

Assesses foundational knowledge of data structures and ability to match the right tool to a problem.

What to say

What to avoid

Example answers

Strong: A stack is perfect for tracking browser history — the back button pops the most recent page. A queue works well for processing incoming web requests in the order they arrived.

Weak: A stack is FIFO, right? Or maybe that's a queue — I'd need to look it up before using one in code.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.