File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LinkedList

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Everybody,

Im currently writing a program that is supposed to read in 10 integers from the user store them in linked list values and I'm supposed to keep them in ascending order at all times. I was wondering if there was a flaw in my logic somewhere that someone can spot because Im only getting correct results when the value im inserting is less than what I start my list at.

psuedocode


Any help would be great.
Thanks.
Hunter.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a nice diagramtic explanation which I think will help you spot your problem...
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying, I read through the site and made some changes to my code but im still getting the same constraint error;



Whats happening is when I increment current if my if statement and the newLink value is > current value it moves current to current.next which is null.
This is where im lost.

Note(I realize this is Ada code but im trying to fix my logic)

Hunter.
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help, I figured it out.

Hunter.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worries and kudos for working it out yourself! It's what we encourage here (hence why I sent you that link)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic