Data Structure & Algorithms: M. Arslan Idris - CS-214
Data Structure & Algorithms: M. Arslan Idris - CS-214
Algorithms
M. Arslan Idris| CS-214
int a;
int b;
int c;
int a,b,c,d;
Imagine that we have 100 scores. We need to read them, process them and print them.
We must also keep these 100 scores in memory for the duration of the program. We
can define a hundred variables, each with a different name, as shown in Figure.
same nature !
An array of airplanes
An array of bugs
An array of cards
Array is a container which can hold fix number of items and these items should be
of same type
Most of the data structure make use of array to implement their algorithms.
Following are important terms to understand the concepts of Array.
Index − Each location of an element in an array has a numerical index which is used to
identify the element.
int a[5];
int a[1000];
Each element can be accessed via its index. For example, we can fetch element at index
6 as 9.
The first element of the array has index zero[0]. It means the first element
and last element will be specified as: arr[0] & arr[9] Respectively.
?
int baz [5] = { };