Ch 5 · Linked Lists — Nodes on a Chain · Data Structures & Algorithms

Topic 5 of 10 in Data Structures & Algorithms — Foundations — 2 lessons.

Nodes and Pointers

A linked list does not store items side by side. Instead each node holds a value and a pointer to the next node. The list is just a reference to the first node (the head). Inserting at the front is O(1) — no shuffling — which is its superpower over arrays.

Reversing a Linked List

Reversing a linked list means flipping every next pointer to face backwards. We walk the chain with three references — prev, curr, and the saved next — in a single O(n) pass.

All topics in Data Structures & Algorithms Beginner

  1. Thinking Like a Computer Scientist
  2. Arrays & Lists — The Workhorse
  3. Stacks — Last In, First Out
  4. Queues — First In, First Out
  5. Linked Lists — Nodes on a Chain
  6. Searching — Finding the Needle
  7. Sorting — Putting Things in Order
  8. Recursion — Functions That Call Themselves
  9. Hash Tables — Instant Lookups
  10. Mini-Projects & Practice