Introduction to Array


Array is a collection of variables of same data type that share a common name.
Array is an ordered set which consist of fixed number of elements.
Array is an example of linier data structure.
In array memory is allocated sequentially so it is also known as sequential list.
Consider Following Example in which an array of five elements is stored sequentially in memory.

2000
10
a[0]
2002
20
a[1]
2004
30
a[2]
2006
40
a[3]
2008
50
a[4]
     

In One Dimensional Array location of element A[i] can be calculated using following equation:

LOC (A[i]) = Base_Address + W * (i)
Here,
Base_Address is the address of first element in the array.
W is the word size. It means number of bytes occupied by each element.
Suppose we want to calculate the address of element A [2]. It can be calculated as follow:
Base_Address = 2000, W=2

LOC (A [i]) = Base_Address + W (i)
LOC (A [2]) = 2000 + 2 (2)
  = 2004

Array Operations


Various operations that can be performed on one dimensional array are:
(1) Traversal of Array
(2) Insert Element in Array
(3) Delete Element from Array
(4) Merge two Array

Download Projects


Download Programs