Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » interestin problem..linked lists
Closed Thread
Old 11-26-2006, 05:07 AM   #1 (permalink)
 
True Techie

Join Date: Nov 2005

Posts: 115

i_learn

Default interestin problem..linked lists

allright u haev a linked list.....u have to reverse the order, WITHOUT allocating more anymore memory......

eg:

first->5->10->15->20->25->NULL.

u have to get

25->20->15->10->5

Do not allocate memory......

this is up for discussion......coz i tried solving it...but we dont get our answer papers back....so i cant ever know if i was right!

i_learn is offline  
Old 01-03-2007, 03:31 AM   #2 (permalink)
 
Newb Techie

Join Date: Jan 2007

Posts: 25

ryno

Default

reverse(listVals.begin(), listVals.end());

reverse will allocate some memory, of course. But I, the programmer, did not.

There really is no way to reverse that list without allocating any memory at all.
ryno is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On