CSC 221 Notes - 1
CSC 221 Notes - 1
Ordered List
We will now consider a type of list known as an ordered list. For example, if
the list of integers shown above were an ordered list (ascending order),
then it could be written as 17, 26, 31, 54, 77, and 93. Since 17 is the
smallest item, it occupies the first position in the list. Likewise, since 93 is
the largest, it occupies the last position.
In above example matrix, there are only 6 non-zero elements ( those are 9,
8, 4, 2, 5 & 2) and matrix size is 5 X 6. We represent this matrix as shown
in the above image. Here the first row in the right side table is filled with
values 5, 6 & 6 which indicates that it is a sparse matrix with 5 rows, 6
columns & 6 non-zero values. The second row is filled with 0, 4, & 9 which
indicates the non-zero value 9 is at the 0th-row 4th column in the Sparse
matrix. In the same way, the remaining non-zero values also follow a
similar pattern.
Storage: There are lesser non-zero elements than zeros and thus
lesser memory can be used to store only those elements.
Computing time: Computing time can be saved by logically
designing a data structure traversing only non-zero elements..
Example:
00304
00570
00000
02600
1. Array representation
2. Linked list representation