Browsed by
Tag: reverse linked list

Reverse a Linked List

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;

}