Stacks & Queues
Stacks and queues are the workhorse LIFO and FIFO abstractions behind call stacks, BFS/DFS, buffers, and schedulers. Interviewers use them to test whether you can match an access discipline to a problem and reason about O(1) operation guarantees.
part ofData structures & algorithmsoverview, primer and where to startread it →on this pageshowhide
explore
- Stacks9 questions
- Stack Mechanics5 questions
- Stack Applications4 questions
- Queues8 questions
- Queue Mechanics4 questions
- Queue Applications4 questions
- Deques4 questions
- Ring Buffers4 questions
- Implementation Strategies9 questions
- Array vs Linked Backing4 questions
- Classic Constructions5 questions
- Computer Scienceskillanchors this topic
- Data Structures & Algorithmsskillanchors this topic
- AI & Data Scientistrole
- AI Engineerrole
- AI Red Teamingrole
- Android Developerrole
- Backend Developerrole
- Blockchain Developerrole
- Cyber Security Expertrole
- Data Analystrole
- Data Engineerrole
- DevOps / SRE Engineerrole
- DevSecOps Engineerrole
- Forward Deployed Engineerrole
- Frontend Developerrole
- Full Stack Developerrole
- Game Developerrole
- Java Backend Developerrole
- Java SDETrole
- Kotlin Backend Developerrole
- MLOps Engineerrole
- Machine Learning Engineerrole
- Network Engineerrole
- PostgreSQL DBArole
- QA Engineerrole
- Software Architectrole
- iOS Developerrole
questions
page 2 of 2Should a shared ticket-intake queue be bounded, and what should enqueue report when it is full?
basics
~20 sBound it whenever arrivals are not limited by something else, because an unbounded in-memory queue converts a slow consumer into a dead process. A bounded queue must then report refusal explicitly on enqueue — never accept-and-discard — so every caller owns what happens to the rejected ticket.
In a shared print spooler, what does round-robin across per-user queues change versus one first-in-first-out queue?
basics
~20 sA single first-in-first-out queue is fair to jobs, not to people: one user's five-hundred-page batch delays everyone behind it. Round-robin over per-user queues makes a job's wait depend on how many users are active, not on one user's backlog.
Which minimum-tracking stack design would you standardise on for a memory-capped device fleet, and why?
basics
~20 sAll the candidates are constant time per operation, so the decision is memory under worst-case input versus who has to maintain the clever version. Bound the stack depth first; if the simple paired-value design then fits the cap, standardise on it.
On a memory-capped device, when a fixed-capacity stack fills, do you reject the push or grow the stack?
basics
~20 sOn memory-capped hardware, reject the push and make the rejection visible. A fixed capacity turns an unpredictable out-of-memory failure into a local, testable policy — provided the caller is told and someone has decided which readings may be lost.
showing 31–34 of 34