Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
void invert_list(node **head){   node *temp1=NULL, *temp2==NULL;    while (*head!=NULL){       temp1=*head;       *head=*h...
head (in main)       1         2   3
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
!head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inve...
"head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inve...
#head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inve...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
head          head (in main)(in invert)    or *head (in invert)                     1            2         3temp2(in inver...
!head (in main)       1         2   3
linked list (CMSC 123)
Upcoming SlideShare
Loading in …5
×

linked list (CMSC 123)

683 views

Published on

  • Be the first to comment

  • Be the first to like this

linked list (CMSC 123)

  1. 1. void invert_list(node **head){ node *temp1=NULL, *temp2==NULL; while (*head!=NULL){ temp1=*head; *head=*head->next; temp1->next=temp2; temp2=temp1; } *head=temp2;}
  2. 2. head (in main) 1 2 3
  3. 3. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  4. 4. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  5. 5. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  6. 6. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  7. 7. !head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  8. 8. "head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  9. 9. #head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  10. 10. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  11. 11. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  12. 12. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  13. 13. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  14. 14. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  15. 15. head head (in main)(in invert) or *head (in invert) 1 2 3temp2(in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert) *head=temp2;
  16. 16. !head (in main) 1 2 3

×