3 Data Structures Most Devastated by Pointer Chasing

Linked lists, binary search trees (especially unbalanced ones), and hash tables using separate chaining are notorious for generating cache misses due to their non-contiguous data access patterns and sequential memory dependencies.

The top 3

  1. Linked Lists: The Foremost Cache Killer: Each node access in a linked list typically incurs a cache miss, making sequential traversal up to 100x slower than array access due to constant main memory fetches.
  2. Deep Tree Traversal's Cache Nightmare: Accessing scattered nodes in unbalanced or dynamically allocated trees (like binary search trees) forces the CPU to fetch data from main memory for each hop, crippling search and insert operations.
  3. Chained Hash Tables' Collision Cost: When hash collisions lead to long linked lists (chains) in a hash table, subsequent lookups degrade into costly pointer chasing, negating the speed advantage of hash functions.

Sources

Open the full topic