In which of the following cases, linked list implementations of sparse...
Conventional way needs a storage of m x n.
In the case of linked list implementation of sparse matrices, storage needed will be m + 3 x (the number of non-zero entries).
Only in case (c), both the methods need the same storage of 30.
View all questions of this test
In which of the following cases, linked list implementations of sparse...
Explanation:
In a conventional way of storing a matrix, we use a 2D array to represent the matrix. Each element of the 2D array occupies a fixed amount of memory space, regardless of whether it is a non-zero or zero element. Therefore, the memory space consumed by a conventional representation is equal to the number of rows multiplied by the number of columns.
However, in a linked list implementation of a sparse matrix, we only store the non-zero elements along with their row and column indices. This saves memory space as we do not need to store the zero elements. The memory space consumed by a linked list representation depends on the number of non-zero elements in the matrix, rather than the total number of elements.
Now let's analyze each case:
a) 5 x 6 matrix with 9 non-zero entries:
In this case, there are 9 non-zero entries in a 5 x 6 matrix. The conventional representation would require a 2D array of size 5 x 6, which is 30 elements. However, the linked list representation only needs to store the 9 non-zero elements. Therefore, the memory space consumed by the linked list representation is less than the conventional representation.
b) 5 x 6 matrix with 8 non-zero entries:
In this case, there are 8 non-zero entries in a 5 x 6 matrix. Similar to the previous case, the memory space consumed by the linked list representation is less than the conventional representation.
c) 6 x 5 matrix with 8 non-zero entries:
In this case, there are 8 non-zero entries in a 6 x 5 matrix. The conventional representation would require a 2D array of size 6 x 5, which is 30 elements. The linked list representation, on the other hand, only needs to store the 8 non-zero elements. Therefore, the memory space consumed by the linked list representation is equal to the conventional representation.
d) 6 x 5 matrix with 9 non-zero entries:
In this case, there are 9 non-zero entries in a 6 x 5 matrix. Similar to the previous case, the memory space consumed by the linked list representation is less than the conventional representation.
Therefore, the only case where the linked list implementation of a sparse matrix consumes the same memory space as the conventional way of storing the entire array is when we have a 6 x 5 matrix with 8 non-zero entries.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).