Algorithm Question.. Linked List..
Posted
by AGeek
on Stack Overflow
See other posts from Stack Overflow
or by AGeek
Published on 2010-05-22T17:19:54Z
Indexed on
2010/05/22
17:20 UTC
Read the original article
Hit count: 220
algorithm
|data-structures
Hi,
Scenario is as follows:-
I want to reverse the direction of the singly linked list, In other words, after the reversal all pointers should now point backwards..
Well the algorithm should take linear time.
The solution that i have thought of using another datastructure A Stack.. With the help of which the singly linked list would be easily reversed, with all pointers pointing backwards.. But i am in doubt, that whether the following implementation yeild linear time complexity.. Please comment on this.. And if any other efficient algorithm is in place, then please discuss..
Thanks.
© Stack Overflow or respective owner