0% found this document useful (0 votes)
74 views5 pages

Linked List Representation of Sparse Matrices

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

Linked List Representation of Sparse Matrices

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

Linked List

Representation of
Sparse Matrices
Sparse matrices are matrices where most of the elements are zero.
Representing them with a traditional array can be inefficient due to
the storage of many unnecessary zeros. Linked lists offer a more
space-efficient way to store and process sparse matrices by only
representing the non-zero elements. This presentation will explore
the concept of linked lists as a data structure for representing
sparse matrices.

by Nagashree Avadhani
Sparse Matrix Example:
5x5 Grid
0 0 3 0 0

0 0 0 0 1

2 0 0 5 0

0 0 0 0 0

0 4 0 0 0

This example shows a 5x5 sparse matrix with only a few non-zero
elements. This illustrates the inefficiency of storing all the zeros in
a traditional array. Using a linked list, only the non-zero elements
and their positions are stored, saving significant memory space.
Linked List Representation:
Nodes and Linking
1 Node Structure 2 Row
Each node in the linked list The row number of the non-
represents a non-zero zero element in the matrix.
element of the sparse matrix.
Each node contains three
fields:

3 Column 4 Value
The column number of the The actual value of the non-
non-zero element in the zero element.
matrix.

The nodes are linked together in a specific order, typically based on either
row or column priority. This order allows for efficient traversal and access
to the non-zero elements in the sparse matrix.
Traversing the Linked List: Accessing Elements

Start at Head Follow Links Access Values


The traversal begins from the The traversal continues by For each node, the row, column,
head node of the linked list, which following the links (pointers) from and value fields are accessed to
usually points to the first non-zero one node to the next, based on retrieve the corresponding non-
element in the matrix. the order of the linked list. zero element from the sparse
matrix.

This traversal process allows efficient access to any specific non-zero element of the matrix by navigating the linked
list based on row, column, or value criteria. This method saves computational time and memory space compared to
traversing a full array.
Applications and Real-World Examples
Graph Representation Image Processing Database Systems

Sparse matrices can be used to Images often contain large areas of Sparse matrices are used in
represent graphs where most uniform color, making them database systems for efficient
connections are absent, for suitable for representation as storage and retrieval of data,
example, in social networks. sparse matrices. especially for large datasets with
many missing values.

Linked list representation of sparse matrices proves advantageous in various real-world scenarios where memory
efficiency and speed are crucial. This technique allows for efficient storage and manipulation of large datasets with
minimal computational overhead.

You might also like