Sparse matrix addition

Matrix is defined with a 2-dimensional array that has row and column. An array which has 'm' rows and 'n' columns represent an mXn matrix.Sometimes it happens when a matrix has zero values is more than NON-ZERO values. The matrix which has a greater number of ZERO values in comparison to the non-zero values is known as a sparse matrix.

Algorithm

To add the matrices, we simply traverse through both matrices element by element and insert the smaller element (one with smaller row and col value) into the resultant matrix. If we come across an element with the same row and column value, we simply add their values and insert the added data into the resultant matrix.

Program using C