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
39 practiced

A ring buffer holds a fixed-capacity queue. How do you tell a full buffer from an empty one when head equals tail? Describe at least two ways to resolve this and the trade-offs, and sketch enqueue and dequeue.

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.

MediumTechnical
35 practiced

You need to keep only the last k records of a very large stream, with O(1) insertion, O(1) removal of the oldest record, and occasional random reads within the window. Compare a circular linked list with an array ring buffer.

MediumTechnical
44 practiced

In C, implement a fixed-size circular buffer with init, push, pop, is_full and is_empty. Support a mode where a full buffer overwrites the oldest element and a mode where push returns an error.

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.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.