Results 1 to 8 of 8
  1. #1
    fraB3422 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default 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. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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. #3
    fraB3422 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    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. #4
    fraB3422 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    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. #5
    fraB3422 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    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. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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 11:09 PM.

  7. #7
    fraB3422 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    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. #8
    fraB3422 is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

Similar Threads

  1. Print variable data type
    By BillyB in forum New To Java
    Replies: 1
    Last Post: 01-14-2011, 05:37 PM
  2. how to set NVarchar data type
    By edi.gotieb in forum JDBC
    Replies: 9
    Last Post: 05-19-2010, 02:13 PM
  3. Primitive data type and class
    By Roselicious in forum New To Java
    Replies: 3
    Last Post: 04-19-2010, 04:27 PM
  4. JNI accessing non primitive data type
    By H_P in forum Advanced Java
    Replies: 1
    Last Post: 04-14-2010, 06:43 AM
  5. sychronized data type
    By java girl in forum Threads and Synchronization
    Replies: 3
    Last Post: 02-13-2009, 09:37 AM

Posting Permissions

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