SlideShare a Scribd company logo
1 of 17
Download to read offline
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;
}
head (in main)




       1         2   3
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
!
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
"
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
#
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
head          head (in main)
(in invert)    or *head (in invert)




                     1            2         3
temp2
(in invert)
                                  temp1=*head;
                                  *head=*head->next;
                                  temp1->next=temp2;
                    temp1         temp2=temp1;
                    (in invert)
                                  *head=temp2;
!
head (in main)




       1         2   3

More Related Content

More from MaeEstherMaguadMaralit (7)

The lovedare
The lovedareThe lovedare
The lovedare
 
Cmsc 100 (web content)
Cmsc 100  (web content)Cmsc 100  (web content)
Cmsc 100 (web content)
 
Cmsc 100 (web forms)
Cmsc 100 (web forms)Cmsc 100 (web forms)
Cmsc 100 (web forms)
 
Cmsc 100 xhtml and css
Cmsc 100 xhtml and cssCmsc 100 xhtml and css
Cmsc 100 xhtml and css
 
Cmsc 100 (web programming in a nutshell)
Cmsc 100 (web programming in a nutshell)Cmsc 100 (web programming in a nutshell)
Cmsc 100 (web programming in a nutshell)
 
Chapter2a
Chapter2aChapter2a
Chapter2a
 
Chapter1b
Chapter1bChapter1b
Chapter1b
 

Recently uploaded

Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 

Recently uploaded (20)

prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 

linked list (CMSC 123)

  • 1.
  • 2. 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; }
  • 4. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 5. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 6. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 7. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 8. ! head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 9. " head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 10. # head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 11. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 12. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 13. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 14. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 15. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert)
  • 16. head head (in main) (in invert) or *head (in invert) 1 2 3 temp2 (in invert) temp1=*head; *head=*head->next; temp1->next=temp2; temp1 temp2=temp1; (in invert) *head=temp2;