# Array Representation in Data Structure

## Array:

An array defines as a finite ordered set of homogeneous elements. Finite means that there is a specific number of elements and ordered means that the elements of the array are indexed. Homogeneous means that all the elements of the array must be of the same type.

## Array Representation:

In the Data Structure, there are two types of array representation are exists:

i. One Dimensional Array

ii. Two Dimensional Array

### One Dimensional Array:

Values in a mathematical set are written as shown below :
a={5, 7, 9, 4, 6, 8}
These values refer in mathematics as follows :
a0, a1, a2
In Data Structure, these numbers are represented as follows :
a, a, a
these values are stored in RAM as follows : #### Algorithm for insertion into One-dimensional array:

```Algorithm fnInsertion_1D_Array(arrData, n, k, item)
{
for(i=n-1;i>=k-1;i--)
arrData[i+1]=arrData[i];
arrData[k-1]=item;
n=n-1;
}  // End of Algorithm
```

#### Algorithm for deletion from One-dimensional array:

```Algorithm fnDeletion_1D_Array(arrData, n, k)
{
item=arrData[k-1];
for(i=k-1;i<n-1;i++)
arrData[i]=arrData[i+1];
n=n-1;
return item;
}  // End of Algorithm
```

#### Algorithm for traversing One-dimensional array:

```Algorithm fnTraverse_1D_Array(arrData, n)
{
for(i=0;i<n;i++)
print arrData[i];
}  //End of Algorithm
```

### Two Dimensional Array: These values are referred in mathematical as follows :
A0,0 A0,1 A0,2
In Data Structure, they are represented as follows :
a a a and so on
It may be imagined that these values are stored in RAM as follows : 