encyclopegia.org

Dynamic array

), while some are slow due to the need for reallocation ( time, labelled with turtles). The logical size and capacity of the final array are shown. In computer science, a dynamic array, growable array, resizable array, dynamic table, mutable array, or array list is a random access, variable-size list data structure that allows elements to be added or removed. It is supplied with standard libraries in many modern mainstream programming languages. Dynamic arrays overcome a limit of static arrays, which have a fixed capacity that needs to be specified at allocation. A dynamic array is not the same thing as a dynamically allocated array or variable-length array, either of which is an array whose size is fixed when the array is allocated, although a dynamic array may use such a fixed-size array as a back end.

), while some are slow due to the need for reallocation ( time, labelled with turtles). The logical size and capacity of the final array are shown.]] In computer science, a dynamic array, growable array, resizable array, dynamic table, mutable array, or array list is a random access, variable-size list data structure that allows elements to be added or removed. It is supplied with standard libraries in many modern mainstream programming languages. Dynamic arrays overcome a limit of static arrays, which have a fixed capacity that needs to be specified at allocation. A dynamic array is not the same thing as a dynamically allocated array or variable-length array, either of which is an array whose size is fixed when the array is allocated, although a dynamic array may use such a fixed-size array as a back end. function insertEnd(dynarray a, element e) if (a.size == a.capacity) // resize a to twice its current capacity: a.capacity ← a.capacity * 2 // (copy the contents to the new memory location here) a[a.size] ← e a.size ← a.size + 1 As n elements are inserted, the capacities form a geometric progression. Expanding the array by any constant proportion a ensures that inserting n elements takes O(n) time overall, meaning that each insertion takes amortized constant time (so long as any given allocation takes O(1) time). Many dynamic arrays also deallocate some of the underlying storage if its size drops below a certain threshold, such as 30% of the capacity. This threshold must be strictly smaller than 1/a in order to provide hysteresis (provide a stable band to avoid repeatedly growing and shrinking) and support mixed sequences of insertions and removals with amortized constant cost. Dynamic arrays are a common example when teaching amortized analysis. The growth factor for the dynamic array depends on several factors including a space-time trade-off and algorithms used in the memory allocator itself. For growth factor a, the average time per insertion operation is . If memory allocator uses a first-fit allocation algorithm, then growth factor values such as a=2 can cause dynamic array expansion to run out of memory even though a significant amount of memory may still be available. There have been various discussions on ideal growth factor values, including proposals for the golden ratio as well as the value 1.5. Many textbooks, however, use a = 2 for simplicity and analysis purposes. Below are growth factors used by several popular implementations:

References

No reference rows published for this article.

Cite this article

MLA

"Dynamic array." encyclopegia.org, 2026, https://encyclopegia.org/wiki/dynamic-array. Accessed 23 November 2026.

Chicago

"Dynamic array." encyclopegia.org. Accessed November 23, 2026. https://encyclopegia.org/wiki/dynamic-array.

APA

encyclopegia.org. (2026). Dynamic array. Retrieved November 23, 2026, from https://encyclopegia.org/wiki/dynamic-array

Accessed November 23, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Centrality

enwiki · references available

Symphony No. 8 (Schubert)

enwiki · references available

Medium Mark A Whippet

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1375968792 · 0.5 · snapshot enwiki-001375968792

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.