Outline
- Discussion and examples about Arrays
- What is an Array?
- When and where is an Array used?
- Complexity
- Static array usage example
- Dynamic Array implementation details
- Code Implementation
Static Array
- A static array is a fixed length container containing n elements indexable from the range [0, n-1]
- Indexable: It means that each slot/index in the array can be referenced with a number.
- A static array is given as a contiguous chunk of memory.
When and Where is a static Array used?
- Storing and accessing sequential data
- Temporaily storing objects
- Used by IO routines as buffers
- Lookup tables and inverse lookup tables
- Can be used to return multiple values from a function
→ Many programming languages only allow a single return value
- Used in dynamic programming to cache answers to subproblems
Complexity
Complexity of Static/Dynamic Array
- Appending operation to the dynamic array sometimes requries copying all elements to a new larger array, but it happens quite rarely...
Static Array

Static Array Visualization
- Elements in A are referenced by their index
- There is no other way to access elements in an array
- Array indexing is zero-based, meaning the first element is found in position zero
- Elements in an array don't need to be unique