CSData StructuresDiagramBeginner
Linked List
KO: 연결 리스트·EN: Linked List·JA: 連結リスト
A linear data structure where each node stores a value and a pointer to the next node, allowing dynamic resizing without contiguous memory
Table of Contents
Structure Diagram
Linked List Node & Pointer ChainTap a node
ROOTHead [10 | next]
1 linkQuick Answer
What is Linked List?
A linear data structure where each node stores a value and a pointer to the next node, allowing dynamic resizing without contiguous memory. It is a core concept in Data Structures within CS.
Core Principles
Unlike arrays that store elements in contiguous memory, a Linked List connects heap-allocated nodes via pointers or references.
- Singly Linked List: Each node holds a value and a
nextpointer for forward traversal. - Doubly Linked List: Each node holds both
prevandnextpointers, enabling bidirectional traversal andO(1)deletion given a node reference. - Complexity Trade-off: Inserting or removing at a known node takes
O(1)pointer updates, while random access by index requiresO(N)linear traversal from the head.
Practical Takeaways
- Poor CPU cache locality: Scattered heap allocations cause frequent cache misses. In modern hardware, contiguous dynamic arrays (
std::vector,ArrayList) often outperform linked lists even when shifts are required. - Powering O(1) LRU caches: Combining a hash table with a doubly linked list enables
O(1)lookup, promotion to front, and eviction from tail. - Pointer safety: Always rewire neighbor links before releasing a node to prevent broken chains, memory leaks, or dangling references.
Notable Examples
- LRU Caches: Redis eviction policies and browser cache managers moving hot entries to the head.
- Undo/Redo & Browser History: Navigating backward and forward through state snapshots.
- OS Kernel Structures: Linux
list_headmanaging process queues and free memory blocks.