*
The moose likes Programming Diversions and the fly likes a simple but complex problom Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Other » Programming Diversions
Reply locked New topic
Author

a simple but complex problom

Remo Fernandez
Greenhorn

Joined: Feb 18, 2004
Posts: 18
Hi,
I hav a linkedlist problom.i hav tried a lot to resolve it.but i cant.
this linked list allowing new elements to be added to the front and deleted from the front.how can it be modified so that it adds elements to the end of the list rather than the front of the list?.
that means,
when i run this program,if i input 3 Strings as "aa","bb","cc",the current output will be,
cc
aa
bb
i want to change the program so it prints,
aa
bb
cc
it can be done by adding elements to the end of the list rather than the front of the list.anyone can do it??.here's the hint.
HINT ne way is to store a Reference to the last element of the list and use it to access the end of the list. The other way is to traverse from the front to the last node in a similar way to traverse, then once there create a new node and put a reference to it from the last node. You will also need to be careful about the case when you are adding to an empty list.
Remo Fernandez
Greenhorn

Joined: Feb 18, 2004
Posts: 18
nobody hav the logic?..use IQ
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
This sounds a lot like you might be trying to get others to do your homework. Also it's a duplicate. Please don't post the same thing in multiple forums. Followups can go here. Thanks.


"I'm not back." - Bill Harding, Twister
 
 
subject: a simple but complex problom
 
Similar Threads
Recursion: returning a value/not returning a value(void)
a simple problom
A challenge
Linked List Sorting Problems
Linked List Sorting Problem