We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
ARRAY
LW VIUTeCh Asem UlelervaKerle MUN MueCMM Uy C(O e!
Terme) Uae lONmO me CTReCE MII onES
stored in successive or consecutive
Fontesaaley aya ove-taleyeln
™For example an array may contains all
integer or character elements, but not
loYeyaeeFollowing are the important terms to understand the concept of Array.
= Element - Each item stored in an array is called an element
™ Index - Each location of an element in an array has a numerical index, which is
used to identify the element.
(array Representation }
Arrays can be declared in various ways in different languages. For illustration, let's take C
array declaration
int array [10] = { 35, 33, 42, 10, 14, 19, 27, 44, 26, 31 }
T
Arrays can be declared in various ways in different languages. For illustration, let's take C
array declaration
elements | 35 | 33 | 42 | 10 | 14|/ 19 | 27 | 44 | 26 | 31 "A
index o 12 345678 9
Size :10Types of Arrays
™ Array can be categorized into different
ine Wa arvae
** One dimensional array
** Two dimensional array
** Multi dimensional array
Tato |dg Ol m- law]
Length = UB-LB+1
Where , UB is a Upper Bound & LB is a Lower BoundARRAY OPERATIONS
™There are several operations that can be
performed on an array. They are
"Insertion
"Deletion
"Traversal
id CALS ESTOS
"Sorting
"SearchingInsertion:
"Insertion is nothing but adding a new
(Sunes moet Va
™ Here through a loop, we have shifted the
numbers, from the specified position, one
place to the right of their existing
position.
™Then we have placed the new number at
the vacant place.™ Before insertion :
ie
TT al
0) 1 23 4
» After insertion:
13 14 «4
ee v ) 4
™ Fig: shifting the elements to the right while
Insuring an element at 2” positionDeletion:
™ Deletion is nothing but process of remove
an element from the array.
™ Here we have shifted the numbers of
placed after the position from where
the number is to be deleted, one place to
the left of their existing positions.
™The place that is vacant after deletion of
an element is filled with ‘0’.™ Before deletion:
ihn
(0) 1
@ After deletion:
i en oe
0 i 2 3
= Fig: shifting the elements to the left while
deleting 3" element in an array.Traversal:
™ Traversal is nothing but display the
[Sentselecw nmi lerva eA
all 22.69
for (i=0;1<5;i++)
i
Printf (“%d\t”, afi]);
Y
sf
ilSorting:
™ Sorting means arranging a set of data
in some order like ascending or
descending order.@ Before sorting:
nee
6 Ss i
(tN) 2 |e
@ After sorting:Searching:
™Searching is the process of finding the
location of an element with a given
element in a list..
™Here searching is starts from 0" element
and continue the process until the given
specified number is found or end of list is
reached.alo)
al6]_ al?)
ala]
als]
af10
a1
>
alt} a2] af3) al4]
els]
5
Ei
8
22
7
10