SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
GANDHINAGAR INSTITUTE OF TECHNOLOGY
Computer Engineering Department
Data Structures (2130702)
Sparse matrix and its representation
Prepared By : Vardhil Patel
Enrolment No : ___________
Guided By:
Prof. ___________
Sparse matrix and its representation
Matrics play a very important role in solving many
interesting problem in various scientific and
engineering application. It is therefore necessary for us
to design efficient representation for matrices.
Normally matrices are represented in a two
dimensional array. In a matrix, if there are m rows and
n columns and then the space required to store the
numbers will be m*n*s where s is the number of bytes
required to store the value. Suppose there are 10 rows
and 10 columns and we have to store the integer values
then the space complexity will be bytes.
10*10*2=200 bytes.
Sparse Matrices
• Sparse matrix … many elements are zero means sparse
matrix has very few non zero elements
• Time complexity of the matrix will be O(n^2),because
the operations that are carried out on matrices need to
sces one row at a time and individual columns in that
row, results in use of two nested loops,
• Example: if the matrix is of size 100*100and only 10
elements are non zero. Then for accessing these 10
elements one has to make 10000 times scan. also only
10 spaces will be with non zero elements remaining
space of matrix will be filled with zeros only. i.e. we
have to allocate the memory of 100*100*2=2000.
Representation of sparse matrix:
• The representation of sparse matrix will be a triplet
only.
• In the sense that basically the sparse matrix means
very few non zero elements having in it rest of the
spaces are having the values zero which are
basically useless values or simply empty values.so in
this efficient representation we will consider all the
non zero value along with their positions. in a row
wise representation of spare matrix (sparse matrix
is 2D matrix) the 0th row will store total rows of the
matrix, total column of the matrix and total non
zero value
EXAMPLE:
0 0 3 0 4
0 0 5 7 0
0 0 0 0 0
0 2 6 0 0
INDEX ROW NO. COL. NO. VALUES
0 1 3 3
1 1 5 4
2 2 3 5
3 2 4 7
4 4 2 2
5 4 3 6
Chain Representation
row col
nextvalue
Node structure:
Single Chain
row 1 1 2 2 4 4
list = column 3 5 3 4 2 3
value 3 4 5 7 2 6
1 3
3
1 5
4
2
5
2
7
4
2
4
6
3 4 3
null
firstNode
2
One Linear List Per Row
0 0 3 0 4
0 0 5 7 0
0 0 0 0 0
0 2 6 0 0
row1 = [(3, 3), (5,4)]
row2 = [(3,5), (4,7)]
row3 = []
row4 = [(2,2), (3,6)]
valuecolumn
Sparse matrix and its representation data structure

More Related Content

PDF
sparse matrix in data structure
PPTX
PPT
Complements
PPTX
Deadlock in database
PPT
International Telecommunication Union (ITU)
PPTX
E banking
PDF
E Banking
PDF
Algorithms Lecture 4: Sorting Algorithms I
sparse matrix in data structure
Complements
Deadlock in database
International Telecommunication Union (ITU)
E banking
E Banking
Algorithms Lecture 4: Sorting Algorithms I

What's hot (20)

PPT
PPTX
Binary Tree in Data Structure
PPTX
Classification of datastructure.ppt
PPTX
arrays in c
PPTX
Queue in Data Structure
PPT
Abstract data types (adt) intro to data structure part 2
PPTX
Sorting Algorithms
PPTX
stack & queue
PPTX
Unit I - Evaluation of expression
PPTX
Sparse matrix
PPTX
Arrays In C++
PPTX
Array operations
PPTX
Arrays 1D and 2D , and multi dimensional
PDF
Python programming : Strings
PPTX
Programming in c Arrays
PDF
List,tuple,dictionary
PPTX
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
PPSX
Data Structure (Queue)
PPTX
Linked List
PPT
Queue data structure
Binary Tree in Data Structure
Classification of datastructure.ppt
arrays in c
Queue in Data Structure
Abstract data types (adt) intro to data structure part 2
Sorting Algorithms
stack & queue
Unit I - Evaluation of expression
Sparse matrix
Arrays In C++
Array operations
Arrays 1D and 2D , and multi dimensional
Python programming : Strings
Programming in c Arrays
List,tuple,dictionary
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data Structure (Queue)
Linked List
Queue data structure
Ad

Similar to Sparse matrix and its representation data structure (20)

PPTX
Data strutcure and annalysis topic array
PPTX
polynomial_linked list for electrical engineer
PPTX
Basic of array and data structure, data structure basics, array, address calc...
PPTX
Basic MATLAB-Presentation.pptx
PDF
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
PDF
Arrays and library functions
PPTX
array.pptx
PPTX
Svm Presentation
PDF
Homework Assignment – Array Technical DocumentWrite a technical .pdf
PDF
Tensor representations in signal processing and machine learning (tutorial ta...
PDF
Arrays and library functions
PPTX
arrays.pptx
PPTX
2. Array in Data Structure
PPT
Introduction to Matlab - Basic Functions
PPTX
Introduction to matlab lecture 2 of 4
PPTX
MATLAB - Arrays and Matrices
PPT
Algo>Arrays
PDF
A study on solving Assignment Problem
PPTX
Linear Algebra Presentation including basic of linear Algebra
PPT
Arrays and vectors in Data Structure.ppt
Data strutcure and annalysis topic array
polynomial_linked list for electrical engineer
Basic of array and data structure, data structure basics, array, address calc...
Basic MATLAB-Presentation.pptx
Multiplication of two 3 d sparse matrices using 1d arrays and linked lists
Arrays and library functions
array.pptx
Svm Presentation
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Tensor representations in signal processing and machine learning (tutorial ta...
Arrays and library functions
arrays.pptx
2. Array in Data Structure
Introduction to Matlab - Basic Functions
Introduction to matlab lecture 2 of 4
MATLAB - Arrays and Matrices
Algo>Arrays
A study on solving Assignment Problem
Linear Algebra Presentation including basic of linear Algebra
Arrays and vectors in Data Structure.ppt
Ad

Recently uploaded (20)

PPTX
AgentX UiPath Community Webinar series - Delhi
PPTX
Internship_Presentation_Final engineering.pptx
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
PDF
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PPTX
Road Safety tips for School Kids by a k maurya.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
ETO & MEO Certificate of Competency Questions and Answers
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
TE-AI-Unit VI notes using planning model
PPT
Drone Technology Electronics components_1
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
International Journal of Information Technology Convergence and Services (IJI...
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
anatomy of limbus and anterior chamber .pptx
AgentX UiPath Community Webinar series - Delhi
Internship_Presentation_Final engineering.pptx
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
Road Safety tips for School Kids by a k maurya.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Structs to JSON How Go Powers REST APIs.pdf
ETO & MEO Certificate of Competency Questions and Answers
July 2025: Top 10 Read Articles Advanced Information Technology
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
TE-AI-Unit VI notes using planning model
Drone Technology Electronics components_1
Arduino robotics embedded978-1-4302-3184-4.pdf
International Journal of Information Technology Convergence and Services (IJI...
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
anatomy of limbus and anterior chamber .pptx

Sparse matrix and its representation data structure

  • 1. GANDHINAGAR INSTITUTE OF TECHNOLOGY Computer Engineering Department Data Structures (2130702) Sparse matrix and its representation Prepared By : Vardhil Patel Enrolment No : ___________ Guided By: Prof. ___________
  • 2. Sparse matrix and its representation Matrics play a very important role in solving many interesting problem in various scientific and engineering application. It is therefore necessary for us to design efficient representation for matrices. Normally matrices are represented in a two dimensional array. In a matrix, if there are m rows and n columns and then the space required to store the numbers will be m*n*s where s is the number of bytes required to store the value. Suppose there are 10 rows and 10 columns and we have to store the integer values then the space complexity will be bytes. 10*10*2=200 bytes.
  • 3. Sparse Matrices • Sparse matrix … many elements are zero means sparse matrix has very few non zero elements • Time complexity of the matrix will be O(n^2),because the operations that are carried out on matrices need to sces one row at a time and individual columns in that row, results in use of two nested loops, • Example: if the matrix is of size 100*100and only 10 elements are non zero. Then for accessing these 10 elements one has to make 10000 times scan. also only 10 spaces will be with non zero elements remaining space of matrix will be filled with zeros only. i.e. we have to allocate the memory of 100*100*2=2000.
  • 4. Representation of sparse matrix: • The representation of sparse matrix will be a triplet only. • In the sense that basically the sparse matrix means very few non zero elements having in it rest of the spaces are having the values zero which are basically useless values or simply empty values.so in this efficient representation we will consider all the non zero value along with their positions. in a row wise representation of spare matrix (sparse matrix is 2D matrix) the 0th row will store total rows of the matrix, total column of the matrix and total non zero value
  • 5. EXAMPLE: 0 0 3 0 4 0 0 5 7 0 0 0 0 0 0 0 2 6 0 0 INDEX ROW NO. COL. NO. VALUES 0 1 3 3 1 1 5 4 2 2 3 5 3 2 4 7 4 4 2 2 5 4 3 6
  • 7. Single Chain row 1 1 2 2 4 4 list = column 3 5 3 4 2 3 value 3 4 5 7 2 6 1 3 3 1 5 4 2 5 2 7 4 2 4 6 3 4 3 null firstNode 2
  • 8. One Linear List Per Row 0 0 3 0 4 0 0 5 7 0 0 0 0 0 0 0 2 6 0 0 row1 = [(3, 3), (5,4)] row2 = [(3,5), (4,7)] row3 = [] row4 = [(2,2), (3,6)] valuecolumn