Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ALGORITHMS
Module 2
SPARSE MATRIX
SPARSE ARRAY
A special array that contains more number of zero
Eg:
No of zero elements =6
SPARSE MATRIX
A sparse matrix =2D sparse array
A matrix is said to be a sparse matrix if most of its
are non-zero
Alternative Representations
Triplet contains
row number of the non-zero element
column number of the non-zero element
Value of non-zero element
1 0 0 0
0 0 5 0
0 0 0 0
3
Question
Convert sparse matrix to tuple matrix
0000
7090
0005
Convert
sparse matrix
to
tuple matrix
SUM[0][0]=r1
SUM[0][1]=c1
SUM[0][2]=elem
Stop
Solution:
Diagonal matrix
A matrix in which only diagonal elements are non-zero
1