InterviewStack.io LogoInterviewStack.io

Linked Lists Stacks and Queues Questions

Covers core singly and doubly linked list concepts and the fundamental abstract data types stack and queue. For linked lists this includes node structure, traversal, insertion at head and tail, deletion, reversal, finding middle, merging, detecting cycles, removing duplicates, intersection detection, and pointer manipulation details for languages with manual memory management. For stacks and queues this includes LIFO and FIFO semantics, push, pop, peek, enqueue, dequeue, circular buffer implementations, and implementing one with the other (for example queue with two stacks). Also includes array versus linked list implementations, complexity analysis for time and space, and common algorithmic patterns that use these structures (for example bracket matching, reverse polish notation evaluation, depth first search using a stack, breadth first search using a queue, sliding window and monotonic queue techniques). Interviewers assess correct implementation, edge case handling, performance tradeoffs, and ability to choose the appropriate structure or approach for a problem.

EasyTechnical
0 practiced
Implement a Stack class in Python using a singly linked list as the underlying storage. Provide methods: push(x), pop(), peek(), is_empty(), and size(). Explain why this is a suitable choice for LIFO semantics in recursive algorithm conversions (e.g., DFS).
HardTechnical
0 practiced
Given a directed acyclic computation graph (DAG) representing model operations, implement topological sort using a queue (Kahn's algorithm). Provide Python-style pseudocode, analyze complexity, and explain how cycle detection maps to invalid computation graphs in ML frameworks (e.g., accidental cyclic dependencies).
EasyTechnical
0 practiced
Implement a function in Python that finds the middle node of a singly linked list in one pass and O(1) space. If the list has even length, return the second middle node. Explain how this two-pointer technique is useful in merging or splitting data structures for parallel ML workloads.
MediumTechnical
0 practiced
Implement an evaluator for Reverse Polish Notation expressions (RPN) in Python. Support integers and the operators +, -, *, /. Example: input: ['2','1','+','3','*'] -> output 9. Explain how stacks are used here and where RPN might appear in ML systems (e.g., expression-based feature computations or custom layer DSLs).
HardTechnical
0 practiced
Reorder a linked list in-place: given L0→L1→…→Ln-1→Ln, transform it into L0→Ln→L1→Ln-1→L2→Ln-2→… without allocating extra nodes. Implement in Python and explain steps (find middle, reverse second half, merge). Discuss how similar transformations might be used to interleave data sources for training fairness.

Unlock Full Question Bank

Get access to hundreds of Linked Lists Stacks and Queues interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.