Data Structure #2: Arrays
Data Structure #2: Arrays
Arrays
CS214, Data Structures
The Array
Most commonly used data structure
Common operations
Insertion
Searching
Deletion
How do these differ for an ordered array?
How do these differ for an array which does not allow
duplicates?
Array Storage
An array is a collection of data of the same type
Stored linearly in memory:
Remember, value vs. reference
In Java:
Data of a primitive type is a ____________.
All objects are ________________.
But, one nice thing is that arrays are objects. So you can access
its size easily:
int arrayLength = intArray.length;
Ask ourselves:
How could we make the initialization shorter?
How could we save declaring nElems?