Linked Lists

Linked lists: nodes joined by references, so inserting and deleting is a rewire instead of a shift, at the price of reading by position.

  • 9 cards
  • 4 questions
  • About 24 min
  • Beginner to Intermediate
Share

A linked list keeps each element in its own node, joined to the next by a reference, so the elements can sit anywhere in memory and the order lives in the references. It matters because a change at a node the program already holds costs a few rewired references instead of a shift of every element after it, and because later structures, such as a queue or a cache that tracks recent use, are often built on one. The topic starts with nodes, the head and the tail, and why reading by position walks from the start. It then inserts and deletes by rewiring in an order that keeps every node reachable, builds a list in Python, Java and TypeScript, and shows how a tail left behind loses data without an error. It ends with the doubly linked list, what its back reference buys, and when a linked list beats a dynamic array at all.

Contents

9 cardsnot started