Lecture#11
Arrays
,Today’s Lecture Contents
Arrays
Declaration (without values, using a loop, using a list)
Assigning array values
Accessing array values
Searching Arrays (Linear, Binary)
Sum / average of array values
Largest / smallest array element
Sorting Arrays (Ascending / Descending)
Bubble Sort
Selection Sort
Character Arrays
,Arrays
In C++, an array is fixed-size collection of data
values with same data-type
An array means: multiple variables, one name, use of index,
same type and contiguous memory
C++ allows the initialization of all elements on declaration
time
All array elements can be initialized using a loop too
Array elements can be individually accessed using the name
of array and a zero-based integer index
, Potential Usage of Arrays
Any computing scenario with a collection of homogeneous
data of intermediate size
For example:
Processing student marks (assigning grade letters, max, min,
average, most repeating instance etc.)
Processing orders (sum for an interval, max order, min order, other
statistical analysis, cart analysis etc)
Employee Data (calculate salary and other relevant things,
estimating best/worst scenarios etc)
Numerical data etc.