Stack: the hardware call stack is the canonical one, each function call pushes a frame (locals, return address) and each return pops it, which is pure LIFO. Beyond that, an explicit stack is used to evaluate expressions, match brackets / validate the nesting of a protocol frame, and do depth-first traversal or backtracking, often deliberately as an explicit stack in RAM to avoid deep recursion overflowing the limited hardware stack. Queue: an ISR-to-main-loop handoff, the UART RX interrupt enqueues received bytes (or events) into a ring buffer and the main loop dequeues them in arrival order, decoupling the fast producer from the slower consumer. Event loops and task ready-lists are queues for the same reason: things must be handled in the order they arrived.
Data Structures & Algorithms · Interview question
Give a concrete embedded use for a stack and one for a queue.
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Stacks & Queues
LIFO stacks and FIFO queues: the two access disciplines behind the call stack, expression evaluation, and ISR-to-main event passing, and how to back each with fixed memory.
More Stacks & Queues questions
What's the difference between a stack and a queue?How would you implement a queue efficiently, and what's the naive mistake?What does "peek" do, and why does the distinction from "pop" matter?What bounds must you check on a fixed-capacity stack or queue?An ISR enqueues bytes into a ring-buffer queue and the main loop dequeues them. Do you need a lock?How would you implement a FIFO queue using only two stacks, and what's the cost?
Browse all 472 interview questions