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

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

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;