Tuesday, February 4, 2020

10. Moving Last Node to the Front

/*****
Moving Last node to the front of linked list
movelastnodetofront()
*****/
// Lets have two pointer (p,q) one will be one step ahead of other;
// the moment one pointer (p) reaches last node ; point its link to head,
// and put null into q ;
movelastnodetofront()
{

 struct node *p,*q;
 p=head;
  while(p->link != NULL)
{
   
    q=p;
    p=p->link;
}
 q->link= NULL;
 p->link=head;
 head=p;
}

No comments:

Post a Comment

9_Regular Expressions

Regular expressions- Sometimes in HTML, the developer defines more than one class name ( that’s class input has more than one name Here ...