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

Sparse Matrix Representations Explained

A sparse matrix is defined as a matrix where most elements are zero. It can be represented using two methods: Triplet Representation, which uses a 2D array to store the row index, column index, and value of non-zero elements, and Linked List Representation, where each node contains the row index, column index, value, and a pointer to the next node. Both methods allow efficient access to non-zero values in the matrix.

Uploaded by

Raunak
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)
3 views2 pages

Sparse Matrix Representations Explained

A sparse matrix is defined as a matrix where most elements are zero. It can be represented using two methods: Triplet Representation, which uses a 2D array to store the row index, column index, and value of non-zero elements, and Linked List Representation, where each node contains the row index, column index, value, and a pointer to the next node. Both methods allow efficient access to non-zero values in the matrix.

Uploaded by

Raunak
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 Matrices

Most of the elements of the matrix have zero values, then such a matrix is
termed as sparse matrix
Example:

Sparse Matrix Representations


A sparse matrix can be represented by using two representations-
1. Triplet Representation.
2. Linked List Representation.

Method 1: Triplet 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)

Triplet as –(row, Column, Value)


Example:

Consider the following example of a sparse matrix

Hence, we can directly access only non-zero values.

Method 2: Linked List Representation.

In linked list, each node has four fields; these four fields are defined 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).

Next node: Address of the next node.

Example:

You might also like