Learning path

Full curriculum

Full curriculum

Arrows go from each prerequisite to the units that depend on it. Hover or focus a unit to highlight its path.

Unit content

Choosing between dynamic arrays and linked lists

Dynamic arrays and linked lists can both represent ordered sequences, but their costs come from different physical layouts.

Dynamic arrays

A dynamic array stores elements contiguously. Indexed access is constant-time, traversal has strong spatial locality, and append can be amortized constant-time. Inserting in the middle usually moves later elements.

Linked lists

A linked list stores separate nodes connected by references. If the insertion position is already known, adding or removing a neighboring node can require only a few pointer updates. Reaching an arbitrary position still requires traversal.

Big-O is not enough

A theoretically cheap linked-list operation can lose in practice when finding the node dominates the work or scattered nodes cause cache misses. Conversely, linked structure is valuable when stable node identity or constant-time local splicing is actually needed.

Choose the data structure from the operations and memory-access pattern of the workload, not from one isolated complexity entry.