aspose file tools*
The moose likes Beginning Java and the fly likes linking problems with 2d matrix LL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "linking problems with 2d matrix LL" Watch "linking problems with 2d matrix LL" New topic
Author

linking problems with 2d matrix LL

Andrew Hodel
Greenhorn

Joined: Apr 04, 2013
Posts: 10
hi all im still in the beginning stages of learning programming and i have a project to represent a 2d matrix with a linked list so far this is what i have:

I know that it is at least going through the whole populate method and i know the list is not linked properly because my toString method is a kind of test for it.
I just dont see where my code fails

my toString outputs
0 1 2 3 4 5 6
1 2 3 4 5 6 7
3 4 5 6 7 8
5 6 7 8 9
7 8 9 10
9 10 11
11 12


Happy Coding
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14153
    
  18

Andrew Hodel wrote:I just dont see where my code fails

Why do you think it fails? Don't expect someone else to automatically know what your code is supposed to do. Explain what you expected, and how the actual output differs from what you expected.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Andrew Hodel
Greenhorn

Joined: Apr 04, 2013
Posts: 10
..Ok, the matrix indexing starts at 0,0(row, column) for the top left element and the key value for the node is initiated to row+column so the 7-by-7 matrix should output
0 1 2 3 4 5 6
1 2 3 4 5 6 7
2 3 4 5 6 7 8
3 4 5 6 7 8 9
4 5 6 7 8 9 10
5 6 7 8 9 10 11
6 7 8 9 10 11 12
All nodes have a left and a down pointer except, column 6 has left pointers of null, and row 6 has down pointers of null.
The way i think about doing this is by populating the list for row 0 then keeping a pointer to the "leftMost" element in the row, populate the list for row 1 while creating the correct pointers for the row above the current row. However this is proving much more difficult in practice than conceptually.
Andrew Hodel
Greenhorn

Joined: Apr 04, 2013
Posts: 10
Sorry if anybody was working on a solution but i fixed the problem.. i was make things null and trying to use them to point to things, doesnt work out that well
happy coding
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: linking problems with 2d matrix LL