Professional Documents
Culture Documents
Muhammad Irfan
What is an array?
Array is the collection of similar data items and is
also called a linear data structure.
The data type of all elements of array is the same
and each element of array is referred by one name.
All array elements are stored at contiguous memory
locations and each location have a subscript to
distinguish each element from the other and just
because of this reason array is also sometimes called
subscripted variable.
There are two types of array
One dimensional array
Two dimensional array
One dimensional array
One dimensional array is a finite number of
elements and elements can be stored in one
dimensional array in either row or in column.
A
10 20 30 40 50 60 70
Result 34 21 11 56 83 32 12 43 05
Con’t
The following Dope vector formula is used to
access a particular element of three
dimension array.
loc[A(i,j)] = ba+n(i-1)+(j-1)
where
ba = base address or starting address
n = Total number of columns
i = Row number of a particular element
j = Column number of element
Column-by-Column mapping
That type of mapping in which all the elements
of an array stores column wise that is first
elements of 1st column stores then 2nd column
and so on, is called column by column
mapping
e.g 34 21 11
56 83 32
12 43 05
(1,1) (1,2) (1,3) (2,1) (2,2) (2,3) (3,1) (3,2) (3,3)
34 56 12 21 83 43 11 32 05
Con’t
Formula for accessing a particular element using
dope vector using column-by-column mapping
is as under
loc[A(i,j)] = ba+m(j-1)+(i-1)
where
A = array name
ba= base address or starting address
m = total number of rows
i = particular row number
j = particular column number
Drawback of Dope Vector Method
The main drawback of this method is
the wastage of time.
As accessing a particular item in the
array involves calculation which will
waste some time.
To remove this drawback we will use
the ILIFFE method.