10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

//create a SparseMatrix that can hold up to MaxItems= MaxRow*MaxCol<br />

and whose //maximum row size is MaxRow and whose maximum column<br />

size is MaxCol<br />

SparseMatrix Transpose();<br />

// return the matrix produced by interchanging the row and column value of<br />

every triple.<br />

SparseMatrix Add(SparseMatrix b);<br />

//if the dimensions of a(*this) and b are the same, return the matrix produced<br />

by adding //corresponding items, namely those with identical row and column<br />

values. else return //error.<br />

SparseMatrix Multiply(a, b);<br />

//if number of columns in a equals number of rows in b return the matrix d<br />

produced by //multiplying a by b according to the formula: d[i][j]=<br />

Sum(a[i][k](b[k][j]), where d(i, j) is the (i, j)th element, k=0 ~ ((columns of a) –1)<br />

else return error.<br />

Representation of Sparse Matrix<br />

class SparseMatrix;<br />

class MatrixTerm {<br />

friend class SparseMatrix<br />

private:<br />

int col, row, value;<br />

};<br />

private:<br />

int col, row,Terms;<br />

MatrixTerm smArray[MaxTerms];<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 59 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!