简体   繁体   中英

Multiplication of sparse matrix, linked list

I have 2 sets of sorted linked list A and B, and i want to get product of A * B. for A it's easy since it's just a normal nested for loop. What about B? Initially i thought of haveing 3 nested for loop but since i'll be using pointers so it's impossible to use B[i][j]. any idea guys?

I sort of figured out a way to do it.

while (A != NULL)      //your first list
{                   
                       // store your row value and col in variables
   while (B != NULL)   // second list
   {
      if (colB == rowA) // you check if the b col is equals to a row, if yes you can
                        // start storing the values inside the 3rd link. 



    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM