Sparse matirx can be represented 1-dimensionally, by creating a array of structures, that have members sumc as: Struct RM{int ROW,int COL, int non_zero}; struct RM SM[Number_non_Zeros +1]; then input row,col for each non-zero element of the sparse matrix. if still unclear please fell free to requestion or query on ikit.bbsr@gmail.com, specifying clearly the question in the subject. Chinmaya N. Padhy (IKIT)
what is the disadvantage of sparse matrix?
#include#includevoid main(){int a[10][10],b[10][3],r,c,s=0,i,j;clrscr();printf("\nenter the order of the sparse matrix");scanf("%d%d",&r,&c);printf("\nenter the elements in the sparse matrix(mostly zeroes)");for(i=0;i
This is a directive, not a question.
It's matrix C.
C Examples on Matrix OperationsA matrix is a rectangular array of numbers or symbols arranged in rows and columns. The following section contains a list of C programs which perform the operations of Addition, Subtraction and Multiplication on the 2 matrices. The section also deals with evaluating the transpose of a given matrix. The transpose of a matrix is the interchange of rows and columns.The section also has programs on finding the trace of 2 matrices, calculating the sum and difference of two matrices. It also has a C program which is used to perform multiplication of a matrix using recursion.C Program to Calculate the Addition or Subtraction & Trace of 2 MatricesC Program to Find the Transpose of a given MatrixC Program to Compute the Product of Two MatricesC Program to Calculate the Sum & Difference of the MatricesC Program to Perform Matrix Multiplication using Recursion
what is the disadvantage of sparse matrix?
A sparse matrix is a matrix in which most of the elements are zero.
Another sparse matrix.
A sparse matrix is one which normally contains a large proportion of elements whose value is 0. There is no exact proportion at which a matrix becomes sparse.
write a programe to build a sparse matrix as an array. write function to check if the sparse matrix is a square, diagonal,lower triangular, upper triangular or tridiagonal matrix
A sparse matrix is matrix that allows special techniques to take advantage of large number of zero element. Application of sparse matrix is classification and relationship analysis in large data base system - SPARCOM
A matrix that have one or more elements with value zero.
A sparse matrix is an array with more zero values than non-zero values.
DataStructure-Program to transpose a sparse matrix.#include #include #include #define MAX1 3#define MAX2 3struct sparse{int *sp ;int row ;} ;void initsparse ( struct sparse * ) ;void create_array ( struct sparse * ) ;void display ( struct sparse ) ;int count ( struct sparse ) ;void create_tuple ( struct sparse *, struct sparse ) ;void display_tuple ( struct sparse ) ;void transpose ( struct sparse *, struct sparse ) ;void display_transpose ( struct sparse ) ;void delsparse ( struct sparse * ) ;void main( ){struct sparse s[3] ;int c, i ;for ( i = 0 ; i sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ;for ( i = 0 ; i < MAX1 * MAX2 ; i++ ){printf ( "Enter element no. %d:", i ) ;scanf ( "%d", &n ) ;* ( p -> sp + i ) = n ;}}/* displays the contents of the matrix */void display ( struct sparse s ){int i ;/* traverses the entire matrix */for ( i = 0 ; i < MAX1 * MAX2 ; i++ ){/* positions the cursor to the new line for every new row */if ( i % MAX2 0 )printf ( "\n" ) ;printf ( "%d\t", * ( p.sp + i ) ) ;}}/* deallocates memory */void delsparse ( struct sparse *p ){free ( p -> sp ) ;}
#include#includevoid main(){int a[10][10],b[10][3],r,c,s=0,i,j;clrscr();printf("\nenter the order of the sparse matrix");scanf("%d%d",&r,&c);printf("\nenter the elements in the sparse matrix(mostly zeroes)");for(i=0;i
This is a directive, not a question.
#include <stdio.h> #define MAX1 3 #define MAX2 3 struct sparse { int *sp ; int row ; } ; void initsparse ( struct sparse * ) ; void create_array ( struct sparse * ) ; void display ( struct sparse ) ; int count ( struct sparse ) ; void create_tuple ( struct sparse *, struct sparse ) ; void display_tuple ( struct sparse ) ; void transpose ( struct sparse *, struct sparse ) ; void display_transpose ( struct sparse ) ; void delsparse ( struct sparse * ) ; void main( ) { struct sparse s[3] ; int c, i ; for ( i = 0 ; i <= 2 ; i++ ) initsparse ( &s[i] ); create_array ( &s[0] ) ; printf ( "\nElements in Sparse Matrix: " ) ; display ( s[0] ) ; c = count ( s[0] ) ; printf ( "\n\nNumber of non-zero elements: %d", c ) ; create_tuple ( &s[1], s[0] ) ; printf ( "\n\nArray of non-zero elements: " ) ; display_tuple ( s[1] ) ; transpose ( &s[2], s[1] ) ; printf ( "\n\nTranspose of array: " ) ; display_transpose ( s[2] ) ; for ( i = 0 ; i <= 2 ; i++ ) delsparse ( &s[i] ); } /* initialises data members */ void initsparse ( struct sparse *p ) { p -> sp = NULL ; } /* dynamically creates the matrix of size MAX1 x MAX2 */ void create_array ( struct sparse *p ) { int n, i ; p -> sp = ( int * ) malloc ( MAX1 * MAX2 * sizeof ( int ) ) ; for ( i = 0 ; i < MAX1 * MAX2 ; i++ ) { printf ( "Enter element no. %d:", i ) ; scanf ( "%d", &n ) ; * ( p -> sp + i ) = n ; } } /* displays the contents of the matrix */ void display ( struct sparse s ) { int i ; /* traverses the entire matrix */ for ( i = 0 ; i < MAX1 * MAX2 ; i++ ) { /* positions the cursor to the new line for every new row */ if ( i % MAX2 0 ) printf ( "\n" ) ; printf ( "%d\t", * ( p.sp + i ) ) ; } } /* deallocates memory */ void delsparse ( struct sparse *p ) { free ( p -> sp ) ; }