A Singly Linked List is a linear data structure where elements (called nodes) are connected using pointers. Each node points to the next node in the sequence.
Structure of a Singly Linked List
Each node contains:
-
Data – the value stored
-
Next – a reference (pointer) to the next node
Visually:
-
The list starts with a Head (first node).
-
The last node points to NULL (meaning the list ends).
🔹 Example
If we store: 10 → 20 → 30
It looks like:
↓
[10 | •] → [20 | •] → [30 | NULL]
Key Characteristics
-
Elements are not stored in contiguous memory (unlike arrays).
-
Each node stores the address of the next node.
-
Traversal is one-directional only (forward).
-
Dynamic size (can grow or shrink at runtime).
Basic Operations
-
Insertion
-
At beginning
-
At end
-
At a specific position
-
-
Deletion
-
From beginning
-
From end
-
By value
-
-
Traversal
-
Visiting each node sequentially
-
-
Search
-
Finding a value in the list
-
Advantages
✔ Dynamic size
✔ Efficient insertions/deletions (especially at beginning)
✔ No memory wastage like fixed-size arrays
Disadvantages
✘ No direct access (must traverse from head)
✘ Extra memory needed for pointers
✘ Cannot traverse backward