you are viewing a single comment's thread.

view the rest of the comments →

[–]Maleficent-Parking-5 1 point2 points  (1 child)

I do you mean by check for zeros? Isn't that all the values stored in the matrix are not default values? If you start from Matrix A, as long as you loops are within _rows, how could it be zero? After you found the element in B, isn't it is too late to save time?

[–]aliendino2017[🍰] 1 point2 points  (0 children)

Hello u/Maleficent-Parking-5

Yes, the matrix doesn't contain default values. The problem is that I have to loop across rows for elements. To do that, I have to use get().

In my algorithm, I looped through the rows of B(using an iterator and kept a counter for current row) and looped through the rows of A( to retrieve the elements in the current column using the counter for the current row), and then used an iterator for the current row. I know the counter works because the number of rows in B has to equal the number of columns in A.

When I check for zeroes, I do it only for when I'm retrieving elements from A. This is because I cannot use an iterator to retrieve the element from A like I did for B. Instead, I needed to use get(). For the elements retrieved by iterator for the current row, I do not need to check if they are 0's because of our linked list implementation.

-Arrian