Home
About Us
Contact Us
Bookmark
Saved Bookmarks
Current Affairs
General Knowledge
Chemical Engineering
UPSEE
BSNL
ISRO
BITSAT
Amazon
ORACLE
Verbal Ability
→
Linked List Tutorial
→
Linked List Interview Questions in Linked List Tutorial
→
How To Reverse A Singly Linked List?
1.
How To Reverse A Singly Linked List?
Answer»
First, set a pointer (*current) to
POINT
to the first node i.e. current=head.
Move
AHEAD
until current!=null (till the end)
set another pointer (*next) to point to the next node i.e. next=current->next
store reference of *next in a temporary variable (*result) i.e. current->next=result
swap the result value with current i.e. result=current
And now swap the current value with next. i.e. current=next
return result and repeat from step 2
A linked list can
ALSO
be reversed using
RECURSION
which
ELIMINATES
the use of a temporary variable.
Show Answer
Discussion
No Comment Found
Post Comment
Related InterviewSolutions
What Will You Prefer To Use A Singly Or A Doubly Linked Lists For Traversing Through A List Of Elements?
How To Remove Loops In A Linked List (or) What Are Fast And Slow Pointers Used For?
What Are The Applications That Use Linked Lists?
What Is The Difference Between Singly And Doubly Linked Lists?
What Is A Circular Linked List?
Compare Linked Lists And Dynamic Arrays?
How To Reverse A Singly Linked List?
How To Delete A Node From Linked List?
How To Insert A Node In Random Location In The List?
How To Insert A Node At The End Of Linked List?
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply
Your experience on this site will be improved by allowing cookies. Read
Cookie Policy
Reject
Allow cookies