Linked Lists
Node-and-pointer lists: how they live in memory, the singly/doubly/circular variants, and the core pointer manipulations interviewers expect you to explain step by step. Linked lists are the classic probe for whether you truly understand references, ownership of the 'next' pointer, and cost models beyond Big-O labels.
part ofData structures & algorithmsoverview, primer and where to startread it →on this pageshowhide
explore
- Fundamentals & Memory Model16 questions
- Node-and-Pointer Memory Model4 questions
- Singly vs Doubly vs Circular4 questions
- Sentinel & Dummy-Head Nodes4 questions
- Skip Lists4 questions
- Core Pointer Operations20 questions
- List Reversal4 questions
- Merging & Splitting Sorted Lists4 questions
- Finding the Middle & Runner Technique4 questions
- Deletion Mechanics4 questions
- Cycle Detection (Floyd's Algorithm)4 questions
- Tradeoffs & Practical Use7 questions
- Arrays vs Linked Lists3 questions
- Where Linked Lists Earn Their Keep4 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 2Why does traversal of a long-lived linked list slow down as its nodes get scattered?
basics
~20 sComplexity does not change — both passes are O(n) — but the constant does. A chain built in one burst tends to sit in nearby memory; after months of churn its surviving nodes are spread out, and each hop becomes a memory access that cannot begin until the previous one returns.
Why is a three-branch delete (empty, head, scan) a dummy-head refactor and not just style?
basics
~10 sAll three branches exist because the first node has no predecessor. A dummy head supplies one, collapsing them into a single scan-and-relink and deleting the head-reference reassignment where the real defects live.
Two-speed detection or a visited set for a traversal job hung on a looping escalation chain?
basics
~20 sDecide on what the incident needs. The two-speed walk costs no extra memory and still yields the loop's entry, but re-walks records; remembering every record seen costs memory proportional to the chain and hands you the entire offending path in one pass.
For a linked list node you already hold, when is O(1) removal true and when is it a lie?
basics
~20 sConstant-time removal of a held node is true in a doubly linked list, where the node names both neighbours and two writes unlink it anywhere. In a forward-only list it is a lie: finding the predecessor costs O(n).
Why is merge sort the natural sort for a linked list but quicksort is not?
basics
~20 sMerge sort only reads forward and joins two sorted chains by rewriting links, so its usual output buffer disappears on a list. Quicksort and heapsort assume random access — index arithmetic and cheap in-place swaps — which a chain cannot supply.
What does a one-pass gap-pointer walk to the kth-from-last node buy over counting the length first?
basics
~20 sNot asymptotic speed — both are O(n) and both perform roughly 2n advances. One pass buys a single sweep from the head, which matters when re-walking is expensive or the cursor cannot be restarted. Counting first is usually the clearer code.
Recursive list reversal is called O(1) space; why does that fail on a 10-million-node feed?
basics
~20 sRecursion is not free space: the call stack holds one frame per node, so depth equals list length. Ten million pending frames exhausts the stack long before the walk finishes, making the recursive version O(n) auxiliary space, not O(1).
A diff swaps a trade blotter's backing array for a linked list to make middle inserts O(1). What is your review?
basics
~20 sReject it as written. The O(1) splice applies only at a node already held; a blotter inserting at a found position still walks O(n), and that walk over scattered nodes measures far worse than the array's contiguous shift of the same length.
In an order book where cancels hold a node handle, what does a linked list guarantee that a compacted array does not?
basics
~20 sA linked list gives every resting order a stable identity: unrelated inserts and removals never move a node, so a handle taken at insert time is still valid at cancel time. An array index names a position, and compaction or growth silently renames every later order.
Is the prev pointer worth its memory across 10 million nodes, and what do you lose without it?
basics
~20 sKeep prev only for backward movement or O(1) unlink at externally held nodes. At ten million nodes it costs a machine word each — tens of megabytes. If deletes happen during a traversal you already run, a trailing reference does the same for free.
Which bugs does a dummy head sentinel fail to prevent, and which one does it add?
basics
~20 sA sentinel only removes the missing-predecessor branches. Length, search, iteration and the value handed back to callers must all start after it, and a sentinel carrying a default payload can be matched by a scan that forgets to skip it.
When does a skip list beat a balanced search tree for a concurrently updated, price-ordered catalog index?
basics
~20 sA skip list wins when many threads mutate the index: its updates rewire a few neighbouring pointers with no rebalancing, so fine-grained locking and lock-free variants stay tractable, and its bottom level scans price ranges in order. A balanced tree wins when worst-case bounds or memory are contractual.
Your team's standard bans linked lists outright. When would you overrule it, and how would you justify that?
basics
~20 sOverrule the ban only when a property, not a speed hunch, demands it: worst-case constant-time operations with no runtime allocation, or element identity that must survive unrelated mutation. Justify with a measurement, scope it to one module behind an interface, and document the exception.
showing 31–43 of 43