data structures study meterial array and sparse matric
1.
ARRAYS Array isa consecutive set of memory locations and it's mainly used to store similar data. It is a particular method of storing elements of indexed data. Elements of data are stored sequentially in blocks within the array. Each element is referenced by an index, or subscript. The index is usually a number used to address an element in the array. An array is a set of pairs, index and a value. For each index which is defined, there is a value associated with that index. In mathematical terms it is called as correspondence or mapping.
ARRAYS... Simply, declaration ofarray is as follows: int arr[10] Where int specifies the data type or type of elements arrays stores. “arr” is the name of array & the number specified inside the square brackets is the number of elements an array can store, this is also called sized or length of array.
4.
ARRAYS... Following are someof the concepts to be remembered about arrays: The individual element of an array can be accessed by specifying name of the array, following by index or subscript inside square brackets. 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.
5.
ARRAYS... The elements ofarray will always be stored in the consecutive (continues) memory location. The number of elements that can be stored in an array, that is the size of array or its length is given by the following equation: (Upperbound-lowerbound)+1
6.
ARRAYS... For the abovearray it would be (9-0)+1=10,where 0 is the lower bound of array and 9 is the upper bound of array. Array can always be read or written through loop. If we read a one-dimensional array it require one loop for reading and other for writing the array.
ARRAYS... If we arereading or writing two-dimensional array it would require two loops. And similarly the array of a N dimension would required N loops. Some common operation performed on array are: Creation of an array Traversing an array
9.
ARRAYS... Insertion of newelement Deletion of required element Modification of an element Merging of arrays
10.
SPARSE MATRICES Amatrix is a two-dimensional data object made of m rows and n columns, therefore having total m x n values. If most of the elements of the matrix have 0 value, then it is called a sparse matrix. Why to use Sparse Matrix instead of simple matrix ? Storage: There are lesser non-zero elements than zeros and thus lesser memory can be used to store only those elements. Computing time: Computing time can be saved by logically designing a data structure traversing only non-zero elements..
11.
SPARSE MATRICES...... Example 00 3 0 4 0 0 5 7 0 0 0 0 0 0 0 2 6 0 0 Representing a sparse matrix by a 2D array leads to wastage of lots of memory as zeroes in the matrix are of no use in most of the cases. So, instead of storing zeroes with non-zero elements, we only store non-zero elements. This means storing non-zero elements with triples- (Row, Column, value).
12.
SPARSE MATRICES... Thesame time they are sparse: say only 1000 out of one million possible elements are nonzero. On most computers today it would be impossible to store a full 1000 X 1000 matrix in the memory at once. Sparse Matrix Representations can be done in many ways following are two common representations: Array representation Linked list representation
13.
Array Representation 2Darray is used to represent a sparse matrix in which there are three rows named as Row: Index of row, where non-zero element is located Column: Index of column, where non-zero element is located Value: Value of the non zero element located at index - (row,column)
14.
Linked List Representation In linked list, each node has four fields. These four fields are defined as: Row: Index of row, where non-zero element is located Column: Index of column, where non-zero element is located Value: Value of the non zero element located at index - (row,column) Next node: Address of the next node