LearnThatStack Ace your next interview
Computer Science Fundamentals
Linked Lists, Stacks & Queues.
Change topic Change
Practice · Questions

All questions

Showing of 75
Beginner 18
01

What is a linked list, and how does it differ from an array?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A linked list chains elements together using nodes. Each node holds a value and a pointer to the next node. The list only knows where its first node lives. To reach any element you follow pointers one hop at a time.

An array stores elements side by side in one contiguous block. That layout lets you jump straight to index 5 by arithmetic. A linked list cannot; reaching position 5 costs O(n) hops. Arrays give O(1) random access, linked lists give O(n).

The tradeoff flips for growth. An array has a fixed block, so growing may mean copying everything. A linked list just allocates a node and rewires a pointer. Choose based on whether you index often or reshape often.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is the difference between a singly and a doubly linked list?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A singly linked list gives each node one pointer, aimed at the next node. You can only walk forward, from head toward the tail. To reach the previous node you must restart from the head.

A doubly linked list adds a second pointer, aimed at the previous node. Now you can walk both directions. Deleting a node you already hold becomes easy, since you reach its neighbor on each side directly.

That power costs memory. Every node stores an extra pointer, so a million nodes carry a million more references. You also update two links on each insert instead of one. Pick singly when memory is tight and forward-only is enough. Pick doubly when you delete or scan backward often.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is a stack, and what does LIFO actually mean?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A stack is a pile where you only touch the top. You add items on top with push and take them off the top with pop. The bottom stays untouched until everything above it leaves.

LIFO means last in, first out. The most recently added item is the first one you get back. Think of a stack of plates. You wash the last plate you set down, not the first.

This ordering matters when you must reverse or backtrack. Browser back buttons, undo history, and function calls all rely on it. The newest work gets resolved before older work waits underneath.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What is a queue, and what does FIFO actually mean?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A queue is a waiting line. You add items at the back and remove them from the front. Nobody jumps ahead; the order you arrive is the order you leave.

FIFO means first in, first out. The item that waited longest gets served next. A ticket counter works this way. The person at the front, who came earliest, is called first.

This fairness makes queues natural for scheduling and buffering. Print jobs, task runners, and message pipelines process work in arrival order. When order and fairness matter more than recency, a queue fits. It keeps the oldest waiting item from starving behind newer arrivals.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What are the core operations of a stack, and what do they cost?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A stack offers four operations. Push adds an item to the top. Pop removes and returns the top item. Peek reads the top without removing it. IsEmpty reports whether anything is left.

Each of these costs O(1). You only ever touch one end, so nothing shifts or searches. Push and pop just adjust the top position and one value. Peek reads a single slot.

That constant cost is the whole appeal. No matter how many items sit below, the top operations stay instant. This is why stacks handle deep call chains and long undo histories without slowing down.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What are the core operations of a queue, and what do they cost?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A queue offers enqueue, dequeue, front, and isEmpty. Enqueue adds an item at the back. Dequeue removes and returns the item at the front. Front reads that front item without removing it. IsEmpty checks whether any items remain.

Every one of these costs O(1) when built well. You touch only the two ends, front and back, never the middle. A good design keeps a pointer to both ends so neither operation walks the line.

The catch is that phrase, built well. A careless array-backed queue can drift or need shifting. Keeping both ends O(1) takes a ring buffer or a linked list, which later questions cover.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What do insertion and deletion cost in a linked list versus an array?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Inserting or deleting in a linked list costs O(1) once you hold the right node. You rewire a pointer or two and you are done. Nothing else moves. The rest of the list stays exactly where it sat.

An array behaves differently. To insert or delete in the middle, you must shift every later element over one slot. That shift costs O(n). Only changes at the very end avoid it.

There is a catch worth naming. The linked list is O(1) only after you reach the node. Finding it first still costs O(n) hops. Arrays trade cheap access for expensive reshaping; linked lists do the reverse.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

When should you use a linked list instead of an array?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Reach for a linked list when you reshape more than you index. If you constantly insert and remove at points you already hold, its O(1) splicing wins. Queues, playlists, and edit histories fit this shape.

It also helps when size is unpredictable. A linked list grows one node at a time, with no big block to reserve or copy. You never pay a resize that duplicates the whole collection.

Skip it when you need fast access by position. Arrays give O(1) indexing and pack tightly in memory, which the processor loves. If you mostly read by index, an array almost always wins.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

What is a deque, and what can it do that a stack or queue cannot?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A deque, short for double-ended queue, lets you add and remove at both ends. Push and pop work on the front and on the back. It is a queue and a stack fused into one structure.

That is exactly what a plain stack or queue cannot do. A stack only touches one end. A queue adds at one end and removes at the other. Neither gives you free access to both ends at once.

This flexibility earns its keep in real work. Sliding-window scans, work-stealing schedulers, and browser history all lean on both-end access. When a single end is not enough, a deque is the natural next step.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

How do you implement a stack, and what data structure backs it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

You can build a stack on an array or on a linked list. Both keep push and pop at O(1). The choice mostly changes memory behavior, not the contract callers see.

With an array, you track the top index. Push writes at that index and bumps it. Pop reads and steps back. The array grows when full, occasionally copying everything to a bigger block.

With a linked list, the head node is the top. Push adds a new head; pop unlinks it. No copying ever happens, but each node costs an extra pointer.

stack.push(4); // top is now 4
stack.pop();   // returns 4, top restored

Most languages hand you a ready stack through their dynamic array type. Reach for that first.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

How do you implement a queue, and what data structure backs it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A queue needs two access points: one end to add, another to remove. You back it with either a linked list holding head and tail pointers, or a ring buffer over a fixed array. With a linked list, you enqueue at the tail and dequeue at the head, both O(1). The tail pointer is what keeps enqueue cheap; without it you would walk the whole list.

Array-backed queues use two indices that chase each other and wrap around the buffer. That gives O(1) operations with far better cache behavior and no per-node allocation. The catch is fixed capacity, so you either grow the array or reject when full.

Pick the ring buffer when throughput and memory locality matter, like network packet handling. Reach for the linked list when the queue must grow without bound and allocation cost is acceptable.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

12

How do you find the Nth element of a linked list, and what does it cost?

Part of Pro
13

What is a node, and what does each node store in a linked list?

Part of Pro
14

Why does a linked list keep a head pointer, and when do you add a tail?

Part of Pro
15

What is a circular linked list, and where is it used?

Part of Pro
16

What everyday problems do stacks naturally solve?

Part of Pro
17

What everyday problems do queues naturally solve?

Part of Pro
18

Why are stacks and queues defined by their operations rather than their storage?

Part of Pro
Intermediate 27
19

Why is random access slow in a linked list compared to an array?

Part of Pro
20

How does cache locality make arrays faster than linked lists in practice?

Part of Pro
21

What does the extra pointer in a doubly linked list buy you, and what does it cost?

Part of Pro
22

How does a sentinel node remove edge cases from list insertion and deletion?

Part of Pro
23

How do you detect a cycle in a linked list, and what does the idea cost?

Part of Pro
24

What is the idea behind reversing a linked list in place, and its cost?

Part of Pro
25

Why is deleting a node hard when you only have a pointer to it?

Part of Pro
26

What is the real memory overhead of a linked list per element?

Part of Pro
27

When would you back a stack with an array versus a linked list?

Part of Pro
28

When would you back a queue with an array versus a linked list?

Part of Pro
29

Why does a naive array-backed queue waste space, and how do you fix it?

Part of Pro
30

What is a ring buffer, and how do its head and tail wrap around?

Part of Pro
31

How do you implement a deque so both ends stay O(1)?

Part of Pro
32

How do you build a queue from two stacks, and what does it cost?

Part of Pro
33

Why is push on a dynamic-array stack O(1) amortized but not worst case?

Part of Pro
34

What problem shape does a monotonic stack solve at the concept level?

Part of Pro
35

What problem shape does a monotonic queue solve at the concept level?

Part of Pro
36

Where does the call stack fit, and what lives in a stack frame?

Part of Pro
37

What causes a stack overflow, and how deep can recursion go?

Part of Pro
38

When should you replace recursion with an explicit stack?

Part of Pro
39

Why is a queue, not a stack, the right structure for a BFS frontier?

Part of Pro
40

How does a priority queue differ from a plain FIFO queue?

Part of Pro
41

How do skip lists use linked lists to get faster search?

Part of Pro
42

Why is a doubly linked list the backbone of an LRU cache?

Part of Pro
43

How does insertion into a sorted linked list compare to a sorted array?

Part of Pro
44

What makes splicing or splitting linked lists cheap?

Part of Pro
45

Why can't you binary search a linked list efficiently?

Part of Pro
Expert 30
46

How do you implement a stack that returns its minimum in O(1)?

Part of Pro
47

How would you design an undo and redo feature, and why two stacks?

Part of Pro
48

How do you get the maximum over a sliding window using a deque?

Part of Pro
49

How do you build a fixed-capacity LRU cache from a map and a list?

Part of Pro
50

How do schedulers use multiple queues to balance fairness and priority?

Part of Pro
51

How does a work-stealing deque speed up parallel schedulers?

Part of Pro
52

How do you make a queue thread-safe for many producers and consumers?

Part of Pro
53

How would you design a bounded blocking queue?

Part of Pro
54

How does a lock-free queue work, and what makes it so hard?

Part of Pro
55

How do you make a stack thread-safe without serializing every operation?

Part of Pro
56

What happens to a ring buffer when producers outrun consumers?

Part of Pro
57

How does backpressure work when a queue fills faster than it drains?

Part of Pro
58

How would you make a queue durable across process restarts?

Part of Pro
59

How do you shard a queue to scale past one machine's throughput?

Part of Pro
60

How would you design a delayed or scheduled-delivery queue?

Part of Pro
61

What breaks first when one queue must handle a million messages a second?

Part of Pro
62

How do you process a structure whose depth exceeds the stack limit?

Part of Pro
63

How do you free a very long linked list without overflowing the call stack?

Part of Pro
64

What edge cases must a robust doubly linked list implementation handle?

Part of Pro
65

How do you detect and repair a corrupted or self-looping doubly linked list?

Part of Pro
66

How do you safely iterate a linked list while other threads mutate it?

Part of Pro
67

What concurrency hazards come with a shared linked list, and how do you mitigate them?

Part of Pro
68

What cache-miss costs appear when a linked list grows to millions of nodes?

Part of Pro
69

How does an unrolled linked list trade node count for cache performance?

Part of Pro
70

How do intrusive linked lists reduce allocation overhead in systems code?

Part of Pro
71

How do memory allocators use free lists built on linked lists?

Part of Pro
72

What causes memory fragmentation in a long-lived linked list?

Part of Pro
73

How does XOR linking halve pointer memory, and why is it rarely worth it?

Part of Pro
74

When is a linked list still the right choice at large scale?

Part of Pro
75

How do you maintain a linked list of a billion nodes, and what breaks first?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Linked Lists, Stacks & Queues? Send them this set.
Pro · $10/mo

64 of 75 Linked Lists, Stacks & Queues answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git