Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

a simple but complex problom

 
Remo Fernandez
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Report post to moderator
nobody hav the logic?..use IQ
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic