COMP 2140 Lecture 8: 10_01_stack.pdf

39 views31 pages

Document Summary

Purpose: to change the value of entry [r,c] to newvalue. First, search for a node for entry [r,c] There are four possible cases, based on the result of the search and newvalue. Case 1: if there is a node for entry[r,c] and newvalue is not zero, then simply change the value stored in the node to newvalue. Case 2: if there is a node for entry [r,c] and newvalue is zero, then the node should be deleted and. If it is the only node in row r, delete the row (i. e. unlink the header for the row from column 0) If it is the only node in column c, delete the column (i. e. unlink the header for the column from row 0) Case 4: if there is no node for entry [r,c] and newvalue setvalue(r,c,newvalue) examples, starting with the following sparse matrix. If there is already a non-zero value in row r and column c.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers