
Several values are inserted at the end of a dynamic array using geometric expansion. Grey cells indicate space reserved for expansion. Most insertions are fast (
constant time), while some are slow due to the need for
reallocation (
Comparison of list data structures
|
Peek (index) |
Mutate (insert or delete) at … |
Excess space, average |
| Beginning |
End |
Middle |
| Linked list |
Θ(n) |
Θ(1) |
Θ(1), known end element; Θ(n), unknown end element |
Θ(n) |
Θ(n) |
| Array |
Θ(1) |
—N/a |
—N/a |
—
|