Arrays One Liner
# The very common linear structure is array. Since arrays are usually easy to traverse, search and sort, they are frequently used to store relatively permanent collections of data.
# An array is a list of a finite number n of homogeneous data elements (i.e., data elements of the same type) such that:
a) The elements of the array are referenced respectively by an index consisting of n consecutive numbers.
b) The elements of the array are stored respectively in successive memory locations.
Opearations of Array
# Two basic operations in an array are storing and retrieving (extraction)
# Storing : A value is stored in an element of the array with the statement of the form,
Data[i] = X ; Where I is the valid index in the array
And X is the element
# Extraction : Refers to getting the value of an element stored in an array.
X = Data [ i ], Where I is the valid index of the array and X is the element.
# The number n of elements is called the length or size of the array. If not explicitly stated we will assume that the index starts from 0 and end with n-1.
# In general, the length (range) or the number of data elements of the array can be obtained from the index by the formula,
Length = UB – LB + 1
# Where UB is the largest index, called the Upper Bound, and LB is the smallest index, called Lower Bound, of the array.
# If LB = 0 and UB = 4 then the length is,
Length = 4 – 0 + 1 = 5
# The elements of an array A may be denoted by the subscript notation (or bracket notation),
A, A, A, … , A[N]
# The number K in A[K] is called a subscript or an index and A[K] is called a subscripted variable.
# Subscripts allow any element of A to be referenced by its relative position in A.
# If each element in the array is referenced by a single subscript, it is called single dimensional array.
# In other words, the number of subscripts gives the dimension of that array.
# A two-dimensional mXn array A is a collection of m*n data elements such that each element is specified by a pair of integers (such as I, J), called subscripts, with the property that,
0 ≤ I < m and 0 ≤ J < n
# The element of A with first subscript i and second subscript j will be denoted by,
A[i,j] or A[i][j] (in c language)
# Two-dimensional arrays are called matrices in mathematics and tables in business applications; hence two-dimensional arrays are sometimes are called matrix arrays.
# There is a standard way of drawing a two-dimensional mXn array A where the elements of A form a rectangular array with m rows and n columns and where the element A[i][j] appears in row i and column j.
# A row is a horizontal list of elements, and a column is a vertical list of elements.
# The two-dimensional array will be represented in memory by a block of m*n sequential memory locations.
# Specifically, the programming languages will store the array either
1. Column by column, i.e. column-major order, or
2. Row by row, i.e. row-major order.