Programming Fundamentals/Fixed and Dynamic Arrays

Overview
A fixed array is an array for which the size or length is determined when the array is created and/or allocated.

A dynamic array is a random access, a variable-size list data structure that allows elements to be added or removed. It is supplied with standard libraries in many modern programming languages. Dynamic arrays overcome a limit of static arrays, which have a fixed capacity that needs to be specified at allocation.

Discussion
Static arrays have their size or length determined when the array is created and/or allocated. For this reason, they may also be referred to as fixed-length arrays or fixed arrays. Array values may be specified when the array is defined, or the array size may be defined without specifying array contents. Depending on the programming language, an uninitialized array may contain default values, or it may contain whatever values were left in memory from previous allocation. Dynamic arrays allow elements to be added and removed at runtime. Most current programming languages include built-in or standard library functions for creating and managing dynamic arrays.

Key Terms

 * dynamic array
 * A data structure consisting of a collection of elements that allows individual elements to be added or removed.


 * fixed array
 * A data structure consisting of a collection of elements for which the size or length is determined when the data structure is defined or allocated.