English, asked by surevandanareddy, 1 year ago

Algorithm for addition of two sparse matrices

Answers

Answered by mihirsingh994
1
hey
mark as BRAINLIEST ANSWER
Operations on Sparse Matrices
Given two sparse matrices (Sparse Matrix and its representations | Set 1 (Using Arrays and Linked Lists)), perform operations such as add, multiply or transpose of the matrices in their sparse form itself. The result should consist of three sparse matrices, one obtained by adding the two input matrices, one by multiplying the two matrices and one obtained by transpose of the first matrix.

Example: Note that other entries of matrices will be zero as matrices are sparse.

Input :

Matrix 1: (4x4)
Row Column Value
1 2 10
1 4 12
3 3 5
4 1 15
4 2 12

Matrix 2: (4X4)
Row Column Value
1 3 8
2 4 23
3 3 9
4 1 20
4 2 25

Output :

Result of Addition: (4x4)
Row Column Value
1 2 10
1 3 8
1 4 12
2 4 23
3 3 14
4 1 35
4 2 37

Result of Multiplication: (4x4)
Row Column Value
1 1 240
1 2 300
1 4 230
3 3 45
4 3 120
4 4 276

Result of transpose on the first matrix: (4x4)
Row Column Value
1 4 15
2 1 10
2 4 12
3 3 5
4 1 12
Similar questions