an array of linked lists implementation to implement the sparse matrix adt using an array of sorted linked listswe create new sparsematrix classas shown in listing in the constructortwo class fields are createdone to store the number of columns in the matrix and another to store the array of head references to the linked lists in which the matrix elements will be stored an array is created whose size is equal to the number of rows in the matrix the individual elements are initialized to none to represent empty linked lists since there are no non-zero elements in the sparse matrix initially note we did not provide field to store the number of rows as that information can be obtained from the length of the array thusnumrows(simply calls the array' length operation the matrixelementnode classprovided in lines - is modified version of the matrixelement class used in the row component has been removed while the next link field was added in order to use the objects as linked nodes when elements are added to the sparse matrixnodes will be added to the individual linked lists based on the row index of the element thusthe row component does not have to be stored in each node changing element values the setitem method is the main linked list management routine for the underlying structure this method not only provides for the modification of element valuesbut it also handles node insertions for new non-zero elements and node removals when an element becomes zero the three operations handled by this method can be combined to produce an efficient implementation the first step is to position the two external reference variables prednode and curnode along the linked list corresponding to the indicated row index while only the curnode reference will be needed for simple element value modificationprednode will be needed if we have to insert new node or remove an existing node after positioning the two referenceswe can then determine what action must be taken if the element corresponding to the given row and col indices is in the linked listcurnode will be pointing to node and the col field of that node will be that of the element in this caseeither the value stored in the node is changed to the new non-zero value or the node has to be deleted when the new value is zero modifying the value only requires changing the value field of the curnode removing the element entry for zero value is also straightforward since the two external references have been positioned correctly and the links can be changed as outlined in section if the element is not represented by node in the linked list of the corresponding row and the new value is non-zerothen new node must be inserted in the proper position based on the prednode and curnode references the only difference in the insertion operation from that used earlier in the is that the head reference is stored in one of the elements of the listofrows array instead of its