A linked list is a dynamic data structure that stores elements in non-contiguous memory. Unlike arrays, it grows/shrinks at runtime, making it ideal for unpredictable data volumes. Think of it as a chain of “nodes,” where each node holds data and a pointer to the next node.
Key Terminology
- Node: Basic unit (contains data + pointer to previous or next node).
- Head: Pointer to the first node.
- Tail: Pointer to the last node (null in singly linked lists).
- Pointer/Link: Address of the next node.

Node structure
/*
* Basic structure of a node
*/
struct node {
int data; // Data (int, char, etc.)
struct node* next; // Pointer to next node
};Core operations
- Creation
- Traversal
- Insertion
- Deletion
- Search
Why Linked Lists Over Arrays?
Arrays have limitations: fixed size, costly insertions/deletions, and memory wastage. Linked lists solve these:
- Dynamic size: Allocates memory as needed.
- Efficient operations: Inserts/deletes in O(1) time at head.
- No memory waste: Uses only required space.
💡 Use linked lists when: You need frequent insertions/deletions or unknown data size.
Types of Linked Lists
- Singly Linked List:
- Traverse in one direction (head → tail).
- Operations: Insert/delete at start (O(1)), end (
O(n)).
- Doubly Linked List:
- Nodes point to next and previous nodes.
- Enables bidirectional traversal.
- Operations: Insert/delete at start/end (O(1)), other (O(n)).
- Circular Linked List:
- Tail points back to head (loop).
- Operations: Insert/delete at start/end (O(1)), other (O(n)).
- Applications: OS scheduling, multiplayer games.
- Circular Doubly Linked List:
- Combines circular + doubly linked features.
Pros & Cons
| Advantages | Disadvantages |
|---|---|
| Dynamic memory allocation (usage) | No random access (e.g., arr[5]) |
| Fast insertions/deletions | Extra memory for pointers |
| Flexible size |
Real-World Applications (use)
- Undo/Redo: Stored as node states (e.g., text editors).
- Hash Tables: Collision handling via chaining.
- Memory Management: OS memory block allocation.
- Navigation: GPS paths (doubly linked lists).