Data Structures19 sections · 729 units
Open in Course

Intro

Why linked lists matter

Arrays have a fundamental limitation: inserting or deleting elements in the middle costs O(n)O(n) because you must shift everything after the change.

Linked lists solve this problem. Each node stores a value and a pointer to the next node. To insert, you update two pointers. O(1)O(1) work regardless of list size.

The tradeoff? You lose random access. Finding the kk-th element requires walking kk steps from the head. But in many algorithms, you only need sequential access anyway. In this section, I'll teach you pointer manipulation patterns that appear constantly in interviews: reversal, fast-slow pointers for cycle detection, and merging sorted lists.