Arrays: contiguous, same-type, O(1) access. Best at reading; worst at insert/delete in the middle. Static = fixed size; Dynamic = grows when full. Use arrays when you need fast random access; use linked lists when you need frequent insertions.
Use array for: sorting, binary search, hash table buckets, stack/queue backing. Avoid for: frequent insert/delete in middle — use linked list instead.
Pros
O(1) access, cache-friendly, simple
Cons
Fixed/resize cost, slow middle insert/delete
The Good
The Bad
Pitfalls
1. Off-by-one: Looping 1 to n instead of 0 to n-1. Classic bug.
2. "Insert is fast" myth: Only at the end! Middle insert = O(n).
3. Reservation waste: arr[1000] with 1 item still uses space for 1000.
Quick Reference
Quick reference for interviews. The three things: Access O(1), Shift O(n), Start at 0.
"When should you prefer a linked list over an array?"
When you need frequent insertions/deletions in the middle — linked list avoids shifting.