1. Member
Join Date
Feb 2011
Posts
6
Rep Power
0

## Matrix Data Type

I need some help with a programming assignment and I've heard that this forum is pretty good. I have to implement a matrix abstract data type which does not allocate memory for 0 values, using linked lists to implement the matrix class.

If I was storing a matrix, I would use a 2d array, but I'm not familiar with a matrix data type. Any help would be appreciated

2. They're trying to get you to create a sparse array or sparse matrix, a concept that has been discussed quite a bit online. You may wish to Google these terms.

3. Member
Join Date
Feb 2011
Posts
6
Rep Power
0
Ok, I have done some research before on sparce matrix, and know they are composed of mainly 0 values, so if we wanted a matrix abstract data type that didn't allocate space for 0's, I'm not sure how a linked list comes into the equation

4. Member
Join Date
Feb 2011
Posts
6
Rep Power
0
So if I had a matrix:

3 4 0 0
1 0 0 4
9 2 2 0
0 0 1 0

would my Linked List be [3,4,1,4,9,2,2,1]?

5. Member
Join Date
Feb 2011
Posts
6
Rep Power
0
I know how to take a matrix in as an argument in my method, and then add the non 0 elements to a SinglyLinkedList one element at a time, does this seem like the way to go?

6. Your list won't contain simple numbers but objects as you'll need to have some way to retrieve the indices, perhaps storing them with the data. Have a look at this PPT lesson for tips: Sparse Arrays.ppt
Last edited by Fubarable; 02-26-2011 at 10:09 PM.

7. Member
Join Date
Feb 2011
Posts
6
Rep Power
0
Thanks for the powerpoint!

In the example that they use this matrix:

0 0 0 0 0 12
0 0 0 0 0 0
0 0 0 0 0 0
0 8 0 0 0 33
0 0 0 17 0 0
0 0 0 0 0 0

It says to represent the matrix as an array of linked lists would be:

Pos 0 in the list has: 5,12 (meaining col 0 row 5 has a 12)
Pol 3 in the lis has: 1,8 linked to 5,33
Pos 4 in the list has: 3,17

Isn't this only 1 list and each 'node' contains an array of nodes (like node 3 has 2 nodes?

8. Member
Join Date
Feb 2011
Posts
6
Rep Power
0
can anyone show me how to create a linkedListArray?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•