Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views10 pages

Unit-1 Sparse Matrix

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)
6 views10 pages

Unit-1 Sparse Matrix

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
You are on page 1/ 10

Data Structure (KCS-301)

Unit 1
Prepared By
N. U. Khan
Computer Science And Engineering Department
IMS Engineering College, Ghaziabad

N U Khan 1
Application of Array
• Arrays are used to implement mathematical vectors and
matrices, as well as other kinds of rectangular tables.
• Arrays are used to implement other data structures, such as
• 1. Lists
• 2. Heaps
• 3. Hash tables
• 4. Deques
• 5. Queues
• 6. Stacks
• 7. Strings.
• 8. Sparse Marices

N U Khan 2
SPARSE MATRICES
• There is no precise definition of when a matrix
is sparse and when it is not. It is a special case
of simple matrices (2-D array).
• A matrix is said to be sparse matrix if such
matrix have many zero elements ( or has
majority of zero elements )
• Special algorithms have to be followed while
storing a sparse matrix in RAM

N U Khan 3
Type of Sparse Matrices
• There are two type of sparse matrices:
• 1. Structured Non-Zero region Matrices:

• 2. Unstructured Non-Zero region Matrices:

N U Khan 4
Type of Sparse Matrices
• 1. Structured Non-Zero region Matrices:
• The sparse matrices in which all non zero elements are
arranged in a particular structure are called structured non-
zero region matrices. e.g. Diagonal matrix, Tridiagonal matrix

7 0 0 0 0 0 17 0 0 0 0 0
2 4 0 0 0 0 0 41 0 0 0 0
1 -4 9 0 0 0 0 0 91 0 0 0
7 1 9 3 0 0 0 0 0 23 0 0
2 11 -5 12 13 0 0 0 0 0 13 0
9 14 7 -9 11 12 0 0 0 0 0 12

N U Khan 5
Type of Sparse Matrices
• 2. Unstructured Non-Zero region Matrices:
• The matrices having irregular non-zero elements are
called unstructured non-zero region matrices

0 0 4 0 0 0 0
0 -3 0 0 0 0 0
0 0 0 0 0 7 0
8 0 0 11 0 0 0
0 0 0 0 -6 0 0
0 18 0 0 0 0 9
2 0 0 0 0 0 0

N U Khan 6
Memory representation of Sparse Matrices

• We will try to store only non-zero elements


because storing all the elements of this matrix
will be wasting of memory space.
• There are two alternative representation that
will store only non-zero elements:
• 1. Vector representation
• 2. Linked list representation

N U Khan 7
N U Khan 8
Transpose Algorithm for Sparse Matrix
• for each row i do
– Take element (i, j, value) and
– Store it in (j, i, value) of the transpose
end

N U Khan 9
Memory representation of Structured Sparse Matrix

• Obtain the indexing formula for


• Lower left triangular sparse matrix using row
major order
• Lower left triangular matrix using column
major order
• Structured diagonal matrix using row major
order

N U Khan 10

You might also like