Memory layout describes how data objects and their elements are arranged in memory. Arrays store elements contiguously, while linked-list nodes may be separated and connected through pointers or references. section 1.1
The layout creates practical tradeoffs:
- Arrays support direct indexed access and O(1) updates, but fixed-size arrays may require copying during growth. section 1.1
- Dynamic arrays allocate extra space, making insertion O(1) on average and O(n) when resizing is required. section 1.1
- Linked lists add pointer storage and require traversal for access unless a reference to the relevant node is already available. section 1.1
Choosing a representation
Use an array when indexed access matters; consider a linked list when insertion or deletion occurs at a known position and pointer overhead is acceptable. section 1.1




