Linked Lists, Stacks, and Queues Questions

Pointer-based linear structures and the classic problems built on them: singly, doubly and circular linked lists (reversal whole, partial and in groups of k, cycle detection and cycle start with fast/slow pointers, intersection, middle and nth-from-end, merging two or k sorted lists, sorting a list, reordering, palindrome check, rotation, partitioning, duplicate removal, deep copy with random pointers, flattening child lists, sentinel nodes), implementing lists in C, C++ and Rust with attention to pointer handling, ownership and cleanup, array versus linked-list trade-offs including cache locality, stacks, queues and deques (array, linked and circular-buffer implementations, ring-buffer full versus empty, queue from two stacks, min stack, round-robin scheduling), monotonic stacks and queues (next greater element, largest rectangle in a histogram, sliding-window maximum), stack-based expression and bracket evaluation (balanced brackets, Reverse Polish Notation, infix to postfix, calculators), and structure-level builds such as an LRU cache from a hash map plus doubly linked list, undo/redo history, and variants like persistent or unrolled lists. Foundational for coding interviews and for understanding how higher-level structures are built. Concurrent and lock-free queues, memory allocators, general graph traversal, heaps and cache-eviction system design are covered elsewhere.

EasyTechnical
49 practiced

Compare singly, doubly and circular linked lists. For each, give memory overhead, the cost of insert, delete (given the node) and traversal, and a realistic use. Which would you pick for an LRU cache, an undo history and a round-robin scheduler, and why?

EasyTechnical
49 practiced

Why do many linked list implementations use a dummy (sentinel) head node? Show an insertion and a deletion at the head written with and without one, and say what trade-offs the sentinel brings.

EasyTechnical
42 practiced

Implement a fixed-capacity queue on an array with enqueue, dequeue, peek, is_empty and is_full, using wrap-around indices. Walk through a sequence of operations that wraps past the end of the array.

HardTechnical
39 practiced

Why can traversing a linked list be much slower than traversing an array on modern CPUs even when both are O(n)? Explain the hardware effects, then describe the techniques you would use to reduce pointer-chasing costs in a linked structure that must stay linked, such as unrolling or pooling.

MediumTechnical
45 practiced

Simulate a round-robin scheduler: given tasks as (id, duration) pairs and a time quantum q, return each task's finish time in completion order. Explain which structure you use for the ready queue.

Unlock Full Question Bank

Get access to all 16 Linked Lists, Stacks, and Queues interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.