{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Data Str &amp; Algorithm HW Solutions 79

# Data Str &amp; Algorithm HW Solutions 79 -...

This preview shows page 1. Sign up to view the full content.

79 tempc->nextrow = temp; } } 12.9 void SparseMatrix remove(int r, int c) { // First, find the row for (SMhead* crow = row; (crow->index <= r) && (crow->next != NULL); crow = crow->next); if (crow->index != r) ERROR; // Not in array // Now, find the column for (SMhead* ccol = c; (ccol->index <= c) && (ccol->next != NULL); ccol = ccol >next); if (ccol->index != c) ERROR; // Not in array // Now, find the element for (SMElem* temp = crow->first; (temp != NULL) && (temp->col != c); temp = temp->nextcol); if (temp->col != c) ERROR; // Not in array // Now, detatch the element if (temp->prevrow == NULL) {
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (temp->nextrow != NULL) temp->nextrow->prevrow = NULL; } else { temp->prevrow->nextrow = temp->nextrow; if (temp->nextrow != NULL) temp->nextrow->prevrow = temp->prevrow; } if (temp->prevcol == NULL) { crow->first = temp->nextcol; if (temp->nextcol != NULL) temp->nextcol->prevcol = NULL; } else { temp->prevcol->nextcol = temp->nextcol; if (temp->nextcol != NULL) temp->nextcol->prevcol = temp->prevcol; } } 12.10 Transposing a sparse matrix is fairly straightforward. Here is pseudocode: void SparseMatrix::transpose() {...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online