Linked List

A linear collection of data elements called nodes, where each node points to the next.

A linked list is a linear data structure where elements are not stored in contiguous memory locations. Instead, each element (node) contains two parts: the data and a reference (or pointer) to the next node in the sequence. It allows for efficient insertion and deletion at any position during execution.

        graph LR
  Center["Linked List"]:::main
  Rel_graph_data_structure["graph-data-structure"]:::related -.-> Center
  click Rel_graph_data_structure "/terms/graph-data-structure"
  Rel_tree["tree"]:::related -.-> Center
  click Rel_tree "/terms/tree"
  Rel_sorting_algorithm["sorting-algorithm"]:::related -.-> Center
  click Rel_sorting_algorithm "/terms/sorting-algorithm"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 1

🧒 Explain Like I'm 5

Think of a treasure hunt where each clue tells you where to find the next one. The clues don't have to be in the same room; they just need to point to the right place. To find the last clue, you have to follow the path from the very first one.

🤓 Expert Deep Dive

Linked lists eliminate the need for memory reallocation and copying. However, they suffer from poor cache locality because nodes are scattered in memory. Doubly linked lists add a tail pointer and back-references for O(1) deletion if the node address is known.

📚 Sources