awesome-everything RU
↑ Back to the climb

Algorithms from zero

Lists, stacks, queues: free-recall review

Crux Free-recall prompts across the unit. Answer each in your own words first, then reveal the model answer and compare — linked-list cost, reversal, tortoise-and-hare, LIFO/FIFO, and the monotonic stack.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 13 min

Retrieval beats re-reading. For each prompt, say or write a full answer from memory before you open the model answer — the effort of recall is what makes the unit stick.

Goal

Reconstruct the unit’s spine — why a linked list trades indexing for head insertion, how reversal and tortoise-and-hare manipulate pointers, why a stack and a queue are disciplines not structures, and why the monotonic stack is linear — without looking back at the lessons.

Recall before you leave
  1. 01
    Why is index access O(n) on a linked list but O(1) on an array, and what does the linked list gain in return?
  2. 02
    Walk through in-place reversal of a singly linked list. What is the one pointer move you must never skip, and what are the time and space costs?
  3. 03
    Explain the fast-and-slow (tortoise-and-hare) technique. Why must the pointers meet inside a cycle, and why exactly two steps for the fast pointer?
  4. 04
    A stack and a queue can both be backed by an array or a linked list. So what actually distinguishes them, and how do you choose between them for a problem?
  5. 05
    What is a deque, and why does dequeuing a FIFO queue with a naive array shift quietly destroy performance?
  6. 06
    Describe the monotonic stack and the next-greater-element pattern. Why is it O(n) despite having a loop inside a loop?
Recap

If you could reconstruct each answer from memory, you hold the unit’s spine: a linked list trades O(1) indexing for O(1) head insertion because scattering requires traversal; reversal and tortoise-and-hare are disciplined pointer dances where you save links before overwriting them; a stack and a queue are LIFO/FIFO disciplines you pick by required order, never dequeued with shift; and the monotonic stack turns an O(n^2) scan into O(n) by the push-once/pop-once invariant.

Continue the climb ↑Lists, stacks, queues: code reading
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.