Array Data Structure
Array is a collection of elements of same type, stored in sequential memory locations. The elements of array are referenced by the index or subscript of array. Array is a linear type of data structure because the memory locations are sequentially allocated to store the data.
Example: Suppose there is an array – Data – having capacity to store 10 elements then the elements of array will be referred by the index like Data (read as Data of 2), Data etc.
Name of Array: Data
eg: Data = 15
eg: Data = 9
There are some types of arrays like one-dimension, two-dimension and multi-dimensional array. Let’s learn it one by one.
One – Dimensional Array Data Structure:
A linear array with single subscript is known as one-dimensional array. Each element in the array is referenced by a single index or subscript. One-dimensional arrays are frequently used in programming.
Name of Array: DATA
Above example is of one-dimensional array because every element in the array is denoted by single memory location.
Example: Element 99 here is denoted as DATA and 27 by DATA.
DATA = 99
DATA = 27.
Two – Dimensional Array Data Structure:
An array with two subscripts is known as two-dimensional array. A two dimensional array A is a collection of m*n data elements such that each element is specified by a pair of subscript. The two-dimensional arrays are called as matrices in mathematics and table in business applications.
In above array, there are two index values: Row index value and column index value. Row is horizontal element and column is vertical element.Fig: Two-dimensional 3*3 array A.
In this ,
A[1,1] means element of array A of 1st row and 1st column
A[3,2] means element of array A of 3rd row and 2nd column
In above example A[3,2] =2
A[2,2] = 25 and
A[1,3] = 7
Multi – Dimensional Array Data Structure:
An array having more than two subscripts is known as multi-dimensional array. An n- dimensional array B is a collection of m1. m2. m3…. mn data elements in which each element is specified by a list of n integers such as K1, K2, . , . , . ,Kn called subscripts, with the property that
1 ≤ K1 ≤ m1 , 1 ≤ K2 ≤ m2 , . . . , 1 ≤ Kn ≤ mn
The elements of B with subscript K1, K2, . , . , . ,Kn will be denoted by B[K1, K2, . , . , . ,Kn]
In this article we learnt basics about array data structure and their types. This article follows with the operations like insert & delete elements, sorting, searching and other operations we can perform on arrays. We will learn Insert and Delete Operation on Array in the following article of Learning Data Structure Series.