CSC-HC-3016 Data Structures Unit I
CSC-HC-3016 Data Structures Unit I
The first array index value is referred to as its lower bound and in most of the
programming languages it is always 0 and the maximum index value is called
its upper bound. The number of elements in the array, called its range is given
by upper bound-lower bound.
In the case of a two-dimensional array, the following formula yields the number
of bytes of memory needed to hold it:
bytes = size of 1st index × size of 2nd index × size of (base type)
REPRESENTATION OF ARRAYS
The difference between row-major and column-major order is simply that the
order of the dimensions is reversed. Equivalently, in row-major order the
rightmost indices vary faster as one steps through consecutive memory
locations, while in column-major order the leftmost indices vary faster.
SPARSE MATRICES
Matrices with good number of zero entries are called sparse matrices.
Triangular matrices are sparse matrices. A tridiagonal matrix is a square
matrix in which all the elements except for the main diagonal, diagonals on the
immediate upper and lower side are zeroes. Tridiagonal matrices are also
sparse matrices.
Let us consider a sparse matrix from storage point of view. Suppose that the
entire sparse matrix is stored. Then, a considerable amount of memory which
stores the matrix consists of zeroes. This is nothing but wastage of memory. In
real life applications, such wastage may count to megabytes. So, an efficient
method of storing sparse matrices has to be looked into.
0 0 0 0 0 0 0 4
For example, the 3- tuple representation of the matrix6 0 0 0 0 0 0 0 is
0 3 0 0 00 0 1
shown below:
3 8 4
0 7 4
1 0 6
2 1 3
2 7 1