Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
14 views
24 pages
Question
Long question computer science data structure 2nd semester
Uploaded by
srutismita43
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save question ❓ For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
14 views
24 pages
Question
Long question computer science data structure 2nd semester
Uploaded by
srutismita43
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save question ❓ For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save question ❓ For Later
You are on page 1
/ 24
Search
Fullscreen
Question Define sparse matrix ? What are its types ? Explain it with a cuitable example,20:28 "al 8 Q define sparse matrix bo A sparse matrix is one with a large number of zero entries. A more practical definition is that a matrix is sparse If the number or distribution of the zero entries makes it worthwhile to avoid storing or operating on the zero entries. @ Sept 2020 @ pssnhignam.com What is a Sparse Matrix? - Nick Higham People also ask i What is a sparse matrix? v What do you mean by sparse array? v * Q al Discover Search Collections20:29 "sal St Be aea Sparse Matrix (Dat... ce) * Javatpvinticvm Nuw, let's see the representativn vf te sparse matrix. Thie nvn-zerv elements in the sparse matrix can be stvred using triplets that are rvws, cvlumns, and values. There are twv ways tv represent the sparse matrix that are listed as fvllvws - © Array representativn © Linked list representativn Array representativn vf tlie sparse matrix Representing a sparse matrix by a 2D array leads tv thie wastage vf Ivts vf memvry. This is because zerves in the matrix are vf nv use, sv stvring zerves wit nvn-zerv elements i¢ wastage vf memvry. Ty avvid suck wastage, we can stvre vnly nvn-zerv elements. If we etre vnly nvn-zerv elements, it reduces the traversal time and te stvrage space. ADVERTISEMENT20:29" $38 Me ae0m In 2D array representativn vf sparse matrix, tere are tiree fields used that are named as ~ ROW loo) s VALUE © Rew - It is the index vf a rvw wlhiere a nvn- zerv element is Ivcated in thie matrix. © Cvlumn - It is the index vf the cvlumn where a nvn-zerv element is lvcated in thie matrix. © Value - It is the value vf the nvn-zerv element that is lweated at the index (rvw, cvlumn). Example - ADVERTISEMENT20:29" £38 fe acom Let's understand the array representativn vf sparse matrix wit thie lielp vf thie example given belww - Cynsider the sparse matrix - o.12 3 ‘i o}0 405 S| Mat parse Matrix —> 51 Os 6 2}0 020 3}2 000 441000 In te abvve figure, we can vbserve a Sxit sparse matrix evntaining 7 nvn-zerv elements and 13 zerv elements. The abvve matrix vecupies Sx = 20 memvry space. Increasing the size vf matrix will increase tlie wastage space. ADVERTISEMENT20:29 "sa 1, Be acom Table Structure | Row | Column Value al In the abvve structure, first cvlumn represents the Oo Oo 1 1 2 3 4 5 rvws, te secvnd evlumn represents tlie evlumns, and tie third evlumn represents the nvn-zerv value. The first rvw vf thie table represents the triplets. The first triplet represents tliat the value 4 is stvred at Ot rvw and ‘Ast evlumn, Similarly, the seevnd triplet represents tat the value 5 is stvred at the Otfi rw and 3rd evlumn, In a similar manner, all triplets represent tlie stvred Weativn vf the nvn-zerv elements in the matrix.20:33 "nl 38M 2008 Linked List representativn vf the sparse matrix In a linked list representativn, the linked list data structure is used tv represent the sparse matrix. The aiivantage vf using a linked list tv represent the sparse matrix is that the evmplexity vf inserting wr deleting a nvie in a linked lst is lesser thian tlie array. Unlike the array representativn, a nvde in the linked list representativn evnsists vf fur fields. The fyur fields vf the linked list are given as fvllvws ~ ‘Rew - It represents the index vF the rw whiere the nvn-zerv element is Ivcated. Cvlurmn - It represents the index vf the cevlumn whiere the nvn-zerv element is lvcated. Value - It is the value vf the nvn-zerv element that is weated at the index (rvw, cvlumn). Next nvde - It stvres the address vf the next nvde. The nvde structure vf thie linked list representativn20:34 sal BS Me seo Tlie nvde structure vF the linked list representativn vf tie sparse matrix is stivemn in the betvw image ~ Node Structure Example - Let's understand the linked list representativn vf sparse matrix with the Help vf the example given belvw - Cunsider thie sparse matrix - Sparse Matrix ——> wrnao oowol|o aROO| ouom|ny 2000, In the abwve figure, we can vbserve a Uxtt sparse matrix evntaining 5 nvn-zerv elements and 11 zerv elements. Abvve matrix vecupies Ux = 16 memvry space. Inereasing the size vf matrix will increase the wastage space.20:34" 188 Me aeow ‘The linked list representativn vf tle abvue matrix given belww - In tie abvve figure, tHe sparse matrix ie represented in the linked list fvrm. In the nvide, the first field represents thie index vf the rvw, the secvnd field field represents tie index vf the evlumn, the represents the value, and te fvurtl field cvntains the aiddress vf tie next nvde. In the abvve figure, the first field vf the first nvde vf tlie linked list cvntains 0, which means Ot rw, the secvnd field cvntains 2, whiicl means 2" cvlumn, and ‘thie third field cvntains 1 that is the nvn-zerv element. Sy, the first nvile represents that clement 1 is stvred at thie Ot ryw-2"4 cylumn in the given sparse matrix. In a simitar manner, all vf the nvies represent the nvn-zerv elements vF thie sparse matrix. Implementativn vf linked list representativn vf sparse matrix Nvw, let's see the implementativn vf linked list20:34 al #38 Me 2008 Nvw, let's see the implementativn vf array representativn vf sparse matrix in C language. In the prvgram belvw, we will stivw the tabular representativn vf thie nvn-zerv elements vf the sparse matrix stvred in array. ‘include
int main() { 1/ Sparse matrix Kaving size 4*5 int sparse_matrix(4)[5) = { {0,0,6,0,9}, {0,0,4,6,0}, {0,0,0,0,0}, {0,1,2,0,0} i 11 size vt matrix int size=0; fur(int 0; 1
You might also like
2bd13db5813bfe70de6c
PDF
No ratings yet
2bd13db5813bfe70de6c
23 pages
DS Class 7-Sparse Matrix-AI&ML
PDF
No ratings yet
DS Class 7-Sparse Matrix-AI&ML
24 pages
IGNOU MCA MCS-21 Solved Assignments 2011
PDF
No ratings yet
IGNOU MCA MCS-21 Solved Assignments 2011
17 pages
Chapter 12 - Advance Structures
PDF
No ratings yet
Chapter 12 - Advance Structures
110 pages
Array 13
PDF
No ratings yet
Array 13
16 pages
DSC++ Unit-Ii
PDF
No ratings yet
DSC++ Unit-Ii
54 pages
Sparse
PDF
No ratings yet
Sparse
6 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
16 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
8 pages
Week 08 (Sparse Matrix)
PDF
No ratings yet
Week 08 (Sparse Matrix)
12 pages
DS Winter 2019
PDF
No ratings yet
DS Winter 2019
17 pages
Computer
PDF
No ratings yet
Computer
14 pages
Computer
PDF
No ratings yet
Computer
14 pages
Chapter 6
PDF
No ratings yet
Chapter 6
11 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
2 pages
Ds I Unit 2 Notes
PDF
No ratings yet
Ds I Unit 2 Notes
20 pages
3D Array
PDF
No ratings yet
3D Array
8 pages
CSC 221 Notes - 1
PDF
No ratings yet
CSC 221 Notes - 1
4 pages
Computer Termpaper
PDF
No ratings yet
Computer Termpaper
13 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
2 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
17 pages
Linked List Representation of Sparse Matrices
PDF
No ratings yet
Linked List Representation of Sparse Matrices
5 pages
Data Structures Using C (Csit124) Lecture Notes: by Dr. Nancy Girdhar
PDF
No ratings yet
Data Structures Using C (Csit124) Lecture Notes: by Dr. Nancy Girdhar
42 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
10 pages
Module 3 DSA 24
PDF
No ratings yet
Module 3 DSA 24
96 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
12 pages
Array
PDF
No ratings yet
Array
10 pages
Matrix and Graph
PDF
No ratings yet
Matrix and Graph
44 pages
Unit 1 Sparse - Matrix
PDF
No ratings yet
Unit 1 Sparse - Matrix
12 pages
Array
PDF
No ratings yet
Array
20 pages
Array
PDF
No ratings yet
Array
6 pages
Unit Ii: 18Csc201J - Data Structures and Algorithms
PDF
No ratings yet
Unit Ii: 18Csc201J - Data Structures and Algorithms
79 pages
Data Structure - Sy3
PDF
No ratings yet
Data Structure - Sy3
19 pages
Ds Short Questions
PDF
No ratings yet
Ds Short Questions
9 pages
DSA in C
PDF
No ratings yet
DSA in C
21 pages
DS Notes Unit-I To 3
PDF
No ratings yet
DS Notes Unit-I To 3
105 pages
Module 2 Part1 ArrayMatrics
PDF
No ratings yet
Module 2 Part1 ArrayMatrics
37 pages
UNIT4, Unit 5 Final 1
PDF
No ratings yet
UNIT4, Unit 5 Final 1
50 pages
Sparse Matrices 10062021 v1
PDF
No ratings yet
Sparse Matrices 10062021 v1
11 pages
DSA Special
PDF
No ratings yet
DSA Special
72 pages
Performance Comparison of Storage Formats For Sparse Matrices
PDF
No ratings yet
Performance Comparison of Storage Formats For Sparse Matrices
14 pages
DS Solution
PDF
No ratings yet
DS Solution
23 pages
Sparse Matrix
PDF
No ratings yet
Sparse Matrix
13 pages
DSAfile Yash Kaushik
PDF
No ratings yet
DSAfile Yash Kaushik
50 pages
Lec11 B
PDF
No ratings yet
Lec11 B
25 pages
Unit 1
PDF
No ratings yet
Unit 1
65 pages
Notes On Array
PDF
No ratings yet
Notes On Array
5 pages
DS-Module - 3
PDF
No ratings yet
DS-Module - 3
26 pages
Stack. Representations: - Over Array (/ Vector) - Over Linked-List
PDF
No ratings yet
Stack. Representations: - Over Array (/ Vector) - Over Linked-List
43 pages
DS Mod 1
PDF
No ratings yet
DS Mod 1
9 pages
DS Assignmnet
PDF
No ratings yet
DS Assignmnet
6 pages
Data Structures Using C++: Ms - Akhila Shaji Assistant Professor SSM College, Rajakkad
PDF
No ratings yet
Data Structures Using C++: Ms - Akhila Shaji Assistant Professor SSM College, Rajakkad
6 pages
BCAC303 Notes
PDF
No ratings yet
BCAC303 Notes
13 pages
What Is Sparse Matrix in Data Structure
PDF
No ratings yet
What Is Sparse Matrix in Data Structure
2 pages
DS Module 3
PDF
No ratings yet
DS Module 3
29 pages
Matrix Data Structures
PDF
No ratings yet
Matrix Data Structures
11 pages
Lecture 17
PDF
No ratings yet
Lecture 17
7 pages