-2

I want to make vertically sparse matrix using LinkedList. So I mean, Rows of matrix connected to each other with LinkedList nodes. and each row nodes contains index of that row and values. My struct like;

struct Node { 
int index;
int *values;
}Node;

How can I point current row's array which contains values. Its single linkedlist.

  • 1
    This is not an answer to your question, but as a side comment, I hope you know this is about the [least cache-friendly](https://stackoverflow.com/questions/16699247/what-is-cache-friendly-code) way to store a sparse matrix I can think of. Any linear algebra using such matrices will be very inefficient. – Cory Kramer Jul 20 '17 at 11:58
  • I know. But is it possible? How should i contruct that? – Lucas Clayton Jul 20 '17 at 12:00

1 Answers1

0

I think this is not a good way to implement matrix but still if you want to try it you can do it with node structure.

struct node
{
   int data; // data value at every node
   int rowIndex; //index of row
   struct node* next; // next pointer of each node
   struct node* below; // will point to below row node
}

1 -> 2 -> 3 -> N
|    |    |  
4 -> 5 -> 6 -> N
|    |    |
N    N    N
sitaram chhimpa
  • 471
  • 7
  • 12