Array as a Map
- The KeyType is an integer.
- The size of the domain (largest possible key minus smallest)
is not too large.
In this case, the best map to use is an array:
- O(1) and very fast.
- very simple code: a[i]
- no space required for keys (key is the array index).
When it is applicable, use an array in your programs rather than a
- runs faster
- uses less storage
- better software engineering