Singly Linked Lists
Start at the head and follow each next reference to its successor.
Core Intuition & How It Works
A singly linked list chains heap-allocated nodes where each node stores a value and a next pointer. Insertion and deletion at a known node take O(1) pointer updates, while indexed lookup requires O(n) traversal from the head.
In the Byte Sized Algorithms interactive classroom, you can step forward and backward through this algorithm with your keyboard while watching the visual diagram, memory state, and highlighted pseudocode update together.
Time & Space Complexity
| Metric | Complexity |
|---|---|
| Time Complexity | O(1) head insert, O(n) search |
| Space Complexity | O(n) |
| Topic Chapter | Chapter 4: Linked Lists |
| Difficulty Level | Beginner |
Key Pattern to Recognize
Use a dummy sentinel head node to eliminate special cases when inserting or deleting at the beginning of the list.
Common Pitfalls & Edge Cases
Losing the reference to the rest of the list by overwriting a next pointer before saving its target.
Real-World & Technical Interview Applications
Adjacency lists, hash table chaining buckets, memory free lists, and functional persistent sequences.