Results 1 to 8 of 8
Thread: Matrix Data Type
 02262011, 09:08 PM #1Member
 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

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.
 02262011, 09:24 PM #3Member
 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
 02262011, 09:55 PM #4Member
 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]?
 02262011, 10:03 PM #5Member
 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?

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; 02262011 at 10:09 PM.
 02272011, 01:15 AM #7Member
 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?
 02272011, 02:08 AM #8Member
 Join Date
 Feb 2011
 Posts
 6
 Rep Power
 0
Similar Threads

Print variable data type
By BillyB in forum New To JavaReplies: 1Last Post: 01142011, 04:37 PM 
how to set NVarchar data type
By edi.gotieb in forum JDBCReplies: 9Last Post: 05192010, 01:13 PM 
Primitive data type and class
By Roselicious in forum New To JavaReplies: 3Last Post: 04192010, 03:27 PM 
JNI accessing non primitive data type
By H_P in forum Advanced JavaReplies: 1Last Post: 04142010, 05:43 AM 
sychronized data type
By java girl in forum Threads and SynchronizationReplies: 3Last Post: 02132009, 08:37 AM
Bookmarks