Professional Documents
Culture Documents
Week 08 (Sparse Matrix)
Week 08 (Sparse Matrix)
Manipulation
What is Sparse Matrix?
• It is a special case of matrix in which number of zero elements is
more than non-zero elements.
• MATRIX can be defined as a 2D array having ‘m’ rows and ‘n’
columns representing m*n matrix.
Why do we need sparse matrix?
There are two major advantages of sparse matrix:
• Storage: Sparse matrix contains lesser non-zero elements than zero
elements so less memory can be used to store elements. It evaluates only the
non-zero elements.
• Computing Time: In case of searching ‘n’, we need to traverse only the non-
zero elements rather than traversing all the sparse matrix elemnts.
• It saves computing time by logically designing a data structure traversing
nn-zero elements.
Represenation:
There are two representations of sparse matrix:
• Array
• Linked List
[ ]
• Example of Sparse Matrix: 0 0 3 0 4
0 0 5 7 0
𝐴( 5 , 4 )=
0 0 0 0 0
0 2 6 0 0
[ ]
0 0 3 0 4
0 0 5 7 0
𝐴( 5 , 4 )=
0 0 0 0 0
0 2 6 0 0
NODE
Row Column Data Next Pointer
Using Linked List:
ASSIGNMENT 02