0% found this document useful (0 votes)
15 views2 pages

Sparse Matrix

A sparse matrix is defined as a matrix predominantly filled with zero values, while a dense matrix contains mostly non-zero elements. Sparse matrices are advantageous for storage and computing time, as they require less memory and allow for efficient traversal of non-zero elements. They can be represented using triplet or linked list representations, facilitating easier manipulation of non-zero elements.

Uploaded by

ritu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Sparse Matrix

A sparse matrix is defined as a matrix predominantly filled with zero values, while a dense matrix contains mostly non-zero elements. Sparse matrices are advantageous for storage and computing time, as they require less memory and allow for efficient traversal of non-zero elements. They can be represented using triplet or linked list representations, facilitating easier manipulation of non-zero elements.

Uploaded by

ritu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sparse Array

If most of the elements of the matrix have 0 value, then it is called a sparse matrix.

If most of the elements are nonzero, then the matrix is dense.

Why to use Sparse Matrix instead of simple matrix ?

• Storage: There are fewer non-zero elements than zeros, and thus less 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.

Sparse Matrix Representation


A sparse matrix can be represented by using TWO representations; those are as follows...
 Triplet Representation (Array Representation)
 Linked Representation

Array Representation

2D array 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)

This will be represented as 2-D array as,


Rows will be from 0 to number of non-zero elements in matrix
Columns will be from 1 to 3 (hence triplet)
0 0 3

1 1 5

2 2 7

3 0 8

Linked List Representation of Sparse Matrix

The benefit of using a linked list instead of an array to represent the sparse matrix is that it is
simpler to add or remove nodes from a linked list than from an array.
• Row - Row where the non-zero element is located.
• Column - Column where the non-zero element is located.
• Value - It is the value of the non-zero element that is located at the index (row, column).
• Next node - Address of the next node

You might also like