This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

linking problems with 2d matrix LL

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Andrew Hodel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
..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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!