Sparse Matrices: Data Structures and Implementation, Slides of Computer Science

The concept of sparse matrices, which have a large number of zero elements compared to nonzero elements. The inefficiency of storing sparse matrices in a traditional n x n array and proposes an alternative: circular lists that store only nonzero elements. The document also provides a detailed implementation of a sparse matrix data structure using a circular linked list. A sample matrix and an instruction to create it.

Typology: Slides

2012/2013

Uploaded on 03/21/2013

dharmaraaj
dharmaraaj 🇮🇳

4.4

(68)

145 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Abstract Data Types
Sparse Matrices
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Sparse Matrices: Data Structures and Implementation and more Slides Computer Science in PDF only on Docsity!

Abstract Data Types

Sparse Matrices

Sparse Matrices

0 0 0 15

0 4 0 0

12 5 0 0

0 0 11 0

Sparse matrices have a large number of zero

elements in proportion to the number of nonzero

elements.

Storing in n x n array will have a lot of wasted

space.

Alternative: circular lists storing only nonzero

elements.

Circular linked list

Linked Representation for Matrix

Sparse Matrix Data Structure

#define MAX_SIZE 50 /* size of largest matrix */ typedef enum {head, entry} tagfield; typedef struct matrix_node *matrix_pointer; typedef struct entry_node { int row; int col; int value; }; typedef struct matrix_node { matrix_pointer down; matrix_pointer right; tagfield tag; union { matrix_pointer next; entry_node entry; } u; }; matrix_pointer hdnode[MAX_SIZE];