---------------------------------- " Data Structure "---------------------------------------------
Reversing a Singly Linked List
{
int data;
struct node *next;
}*head=NULL,*temp,*ptr;
void reversell()
{ ptr=temp=head;
temp=head->next;
ptr=temp->next;
head->next=NULL;
while(temp)
{
temp->next=head;
head=temp;
temp=ptr;
ptr=ptr->next;
}
}
No comments:
Post a Comment