Why 2× and not +1
Standard · Multiple choice · about 3 min
Two dynamic arrays start at capacity 1 and receive the same 1,000 appends. Array A doubles its capacity when full. Array B adds one cell when full. Which statement is true?
Learn the idea first: Dynamic arrays: capacity, growth, amortized append, a visual lesson.
More Dynamic arrays: capacity, growth, amortized append problems
- Capacity after k appends Warm-up
- Count the copies of n appends Warm-up
- Implement push with doubling Standard
- Implement a dynamic array with pop and shrink Challenge