Arrays
Arrays
STRUCTURE
ARRAYS
LINEAR ARRAY
A linear array is a list of a finite number
of n homogeneous data elements
( that is data elements of the same
type) such that
– The elements are of the arrays are
referenced respectively by an index set
consisting of n consecutive numbers
– The elements of the arrays are stored
respectively in successive memory
locations
LINEAR ARRAY
The number n of elements is called the
length or size of the array.
The index set consists of the integer 1,2,
…n
Length or the number of data
elements of the array can be obtained
from the index set by
Length = UB – LB + 1 where UB is
the
largest index called the upper bound and
LB is the smallest index called the
lower
bound of the arrays
LINEAR ARRAY
Element of an array A may be denoted
by
– Subscript notation A1, A2, , …. , An
– Parenthesis notation A(1), A(2), …. ,
A(n)
– Bracket notation A[1], A[2], ….. ,
A[n]
The number K in A[K] is called
subscript
or an index and A[K] is called a
subscripted variable
LINEAR ARRAY
REPRESENTATION OF
LINEAR ARRAY IN MEMORY
Let LA be a linear array in the memory of the
computer
LOC(LA[K]) = address of the elementLA[K] of
the array LA
The element of LA are stored in the
– Beginning
– Middle
– End
Deletion: Removing an element
– Beginning
– Middle
– End
OPERATIONS ON ARRAYS
OPERATIONS ON ARRAYS
OPERATIONS ON ARRAYS
OPERATIONS ON ARRAYS
TWO DIMENSIONAL
ARRAY
TWO DIMENSIONAL
ARRAY