A data type whose values are sequence of characters.
String
A homogenous collection of data in which each element is identified by its position in the collection.
Array
Pros and cons of string being primitive
more convenient, may operations are built in
implementation are more complex
Pros and cons of strings being array-of-char
Simpler implementation, closer to memory
More manual work, more error-prone
What are the valid values for array subscripts or indices?
if not whole number, returns undefined
The type of the subscript is usually bound ________.
statically
The range of the subscript is usually bound ________.
dynamically
Range is bound statically and storage allocation is done before run time
static array
pros and cons of static array?
p: more efficient since it does not require deallocation, no leak/dangling pointer from deallocation mistakes
c: less flexible
Range is bound statically but storage allocation is done when the declaration is elaborated
Fixed stack-dynamic array
Pros of fixed stack-dynamic array?
allows subprograms to share the same space when not in use
Range and storage are bound dynamically once elaborated
Stack-Dynamic Array
Range and storage are bound when program requests then during execution.
Fixed Heap-Dynamic Array
Array can grow and shrink during program execution
Heap-Dynamic Array
Two implementation-wise to map arrays in memory
Row major order, col major order