An Array Data Structure is used to store similar objects (or data values) in a contiguous block of memory. Array Data Structure has fixed size, which determines the number of data values that can be stored in it.
Array : The C++ Way
In C++ Programming Language, we can declare a static array as follow
int arrayName[100];
Here we have declared an array named as "arrayName" which can store up to 100 values, all of which are of the same type, that is an integer.
Now, we will discuss some advantages and disadvantages of this Data Structure
1 4 2 0
is an array with 4 elements , now we want to insert 3 at 2nd position then we need to move 4,2 and 0 one position further to create space for 3. 1 3 4 2 0
These are 3 simple characteristics of an array, Here you might believe that array is not an efficient Data Structure, but in practice, Advantage of an array can outweight its dis-advantages. This largely depend upon the kind of purpose you want to serve, it might be possible that you don't want to insert or delete element as often as you want to access them, in that case, an array is an absolutely perfect Data Structure.
The sole purpose of introducing this data structure is to make sure you simply don't choose Data Structure based on the number of advantages and disadvantage, but you should always try to analyse importance of Data Structure by considering your problem in mind, for example, if you will be spending a lot of time accessing data values as compared to inserting or deleting them, in that case, we need to give more weight to advantage over disadvantage.