Skip to content
BENIBIX Learn

Linked List

Development🧮 Algorithms & Data StructuresData Structures

Also known as Singly Linked List, Doubly Linked List

A chain of items. Each one holds a value and points to the next.

Think of it like

Think of it like a treasure hunt. Each note tells you where to find the next one.

Example

Jack's music app keeps the play queue as a linked list. Dropping a song from the middle just links its two neighbours together.

Why it matters

It shows the trade in every data structure. Fast changes in one place cost slow reads in another.

Definition

A linked list is a chain of items that point to each other in a line. Each item holds a value and a pointer to the next one. The items do not sit side by side in memory; the pointers join them. Adding or removing an item in the middle is fast, because you only change two pointers. Reaching the 500th item is slow, because you must follow 499 pointers. A doubly linked list also points back to the item before.

Common mistake

Reaching for a linked list in daily code. Arrays are faster for most jobs, because their items sit together in memory.

Key takeaways

  1. 1
    A chain. Each item points to the next.
  2. 2
    Fast to change. Insert or remove anywhere.
  3. 3
    Slow to reach. Walk from the start.

Compare