Categories
Technical

Reverse a Linked List

It is simple just a four lines of code. It will be more useful for students during placement timings.
Code:

Void ReverseLinkedList(node* header)
{
node *temp,*current,*result;
temp=NULL;
result=NULL;
current=header;
while(current!=NULL)
{
temp=current->next;
current->next=result;
result=current;
current=temp;
}
header=result;

}

By intrepidkarthi

I am Karthikeyan, working as a software professional, interested in Travelling, Bike riding, PC Gaming, Reading Novels, Blogging, Writing thamizh poems.

Leave a Reply

Your email address will not be published.