π JavaScript Linked List β Topic Index
A linked list is a linear data structure where each element (node) holds a value and a reference to the next node. JavaScript doesn't have a built-in linked list, so we implement it with classes.
Topics Covered
| # | Topic | Key Concepts |
|---|---|---|
| 1 | Basics | Node class, SLL, DLL, traversal |
| 2 | Operations | Reverse, merge, cycle detection |
| 3 | Interview Questions | 25 classic problems |
Why Linked Lists?
- Dynamic size β no fixed allocation
- O(1) insert/delete β at a known position
- Foundation for stacks, queues, LRU cache, adjacency lists
Common Patterns
- Two pointers (slow/fast) β cycle detection, middle, kth from end
- Dummy head β eliminates edge-case null checks
- Reverse in place β prev/curr/next swap loop
- Divide & Conquer β merge sort on linked list