SlideShare ist ein Scribd-Unternehmen logo
1 von 58
[object Object],[object Object],[object Object],Linked List 10 20 30 10 NULL Node A Node B Node C Node D P
[object Object],[object Object],[object Object],Node DATA POINTER 10 NODE
Declarations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Structure
ADD ,[object Object],[object Object],[object Object],[object Object],[object Object]
If list is empty i.e. P==NULL ,[object Object],[object Object],P Q NULL
If list is empty i.e. P==NULL P Q NULL
If list is empty i.e. P==NULL P Q p=(struct node *) malloc(sizeof(struct node))
If list is empty i.e. P==NULL P Q p=(struct node *) malloc(sizeof(struct node)) P->data=num 10
If list is empty i.e. P==NULL P Q p=(struct node *) malloc(sizeof(struct node)) P->data=num 10 P->link=NULL NULL
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q ,[object Object],[object Object],true
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q ,[object Object],[object Object],false
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C P Q ,[object Object],[object Object],[object Object],[object Object],10 Node D NULL
DISPLAY ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
If list is empty P Q NULL ,[object Object],[object Object],[object Object],[object Object]
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],true o/p : 10 o/p : 20
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],o/p : 10 o/p : 20 o/p : 30
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B NULL Node C P Q ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],false o/p : 10 o/p : 20 o/p : 30
INSERT ,[object Object],[object Object]
If position is 1 10 20 30 Node A Node B Node C NULL Q P
If position is 1 10 20 30 Node A Node B Node C NULL Q P p=(struct node *) malloc(sizeof(struct node));
If position is 1 10 20 30 Node A Node B Node C NULL Q P p=(struct node *) malloc(sizeof(struct node)); p->data=num 5
If position is 1 10 20 30 Node A Node B Node C NULL Q P p=(struct node *) malloc(sizeof(struct node)); p->data=num; 5 p->link=q;
If position is greater than 1 10 20 30 Node A Node B Node C NULL Q P Suppose a node is to be inserted at position 3.
10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; }
10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp
10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp
10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp Node BC q->link=(struct node *) malloc(sizeof(struct node));
10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp Node BC q->link=(struct node *) malloc(sizeof(struct node)); 25 q->link->data=num;
10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp Node BC q->link=(struct node *) malloc(sizeof(struct node)); 25 q->link->data=num; q->link->link=temp;
COUNT ,[object Object],[object Object],[object Object]
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],true counter= 1 counter=2
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],counter=1 counter=2 counter=3
If list is not empty i.e. p!=NULL 10 20 30 Node A Node B NULL Node C P Q ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],false counter=3 counter=1 counter=2
REVERSE ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SEARCH ,[object Object],[object Object],[object Object],[object Object]
SEARCH ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],10 20 30 Node A Node B Node C P Q 40 NULL Node D position=1 position=2 position=3 position=4
SEARCH ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],10 20 30 Node A Node B Node C P Q 40 NULL Node D true position=1 position=2 position=3 position=4
REMOVE ,[object Object],[object Object]
If position is 1 10 20 30 10 NULL Node A Node B Node C Node D P Q
If position is 1 10 20 30 10 NULL Node A Node B Node C Node D P Q ,[object Object]
If position is 1 10 20 30 10 NULL Node A Node B Node C Node D P Q
If position is 1 20 30 10 NULL Node B Node C Node D P Q ,[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],10 20 30 Node A Node B Node C P Q 40 NULL Node D
[object Object],[object Object],[object Object],[object Object],[object Object],10 20 30 Node A Node B Node C P Q 40 NULL Node D
[object Object],[object Object],[object Object],[object Object],[object Object],10 20 30 Node A Node B Node C P Q 40 NULL Node D q->link=q->link->link;
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 7 6 3 Node A Node B Node C 1 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 7 6 3 Node A Node B Node C 1 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 6 7 3 Node A Node B Node C 1 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 3 7 6 Node A Node B Node C 1 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 3 7 6 Node A Node B Node C 1 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 1 7 6 Node A Node B Node C 3 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 1 6 7 Node A Node B Node C 3 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 1 3 7 Node A Node B Node C 6 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 1 3 7 Node A Node B Node C 6 NULL Node D i j
SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link)   {   if(i->data>j->data)   {   temp=i->data;   i->data=j->data;   j->data=temp;   }   } } 1 3 6 Node A Node B Node C 7 NULL Node D i j
Presented by ,[object Object]

Weitere ähnliche Inhalte

Was ist angesagt? (20)

queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Queues in C++
Queues in C++Queues in C++
Queues in C++
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Heaps
HeapsHeaps
Heaps
 
Linked List
Linked ListLinked List
Linked List
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Stack
StackStack
Stack
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix Notations
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Linked list
Linked listLinked list
Linked list
 
Stack
StackStack
Stack
 

Andere mochten auch

DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
Array implementation and linked list as datat structure
Array implementation and linked list as datat structureArray implementation and linked list as datat structure
Array implementation and linked list as datat structureTushar Aneyrao
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked listFahd Allebdi
 
Single linked list
Single linked listSingle linked list
Single linked listSayantan Sur
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)swajahatr
 
Circular linked list
Circular linked listCircular linked list
Circular linked listdchuynh
 
LinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedListLinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedListMarcus Biel
 
Link list CSE ( Data structure ) .
Link list CSE  ( Data structure ) .Link list CSE  ( Data structure ) .
Link list CSE ( Data structure ) .Nirjhor003
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))Papu Kumar
 

Andere mochten auch (20)

Linked lists
Linked listsLinked lists
Linked lists
 
Linked list
Linked listLinked list
Linked list
 
Link List
Link ListLink List
Link List
 
linked list
linked list linked list
linked list
 
Linked list
Linked listLinked list
Linked list
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Array implementation and linked list as datat structure
Array implementation and linked list as datat structureArray implementation and linked list as datat structure
Array implementation and linked list as datat structure
 
Linked lists
Linked listsLinked lists
Linked lists
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Singly link list
Singly link listSingly link list
Singly link list
 
Single linked list
Single linked listSingle linked list
Single linked list
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Infix to postfix
Infix to postfixInfix to postfix
Infix to postfix
 
Linked List
Linked ListLinked List
Linked List
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Linkedlist1
Linkedlist1Linkedlist1
Linkedlist1
 
LinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedListLinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedList
 
Link list CSE ( Data structure ) .
Link list CSE  ( Data structure ) .Link list CSE  ( Data structure ) .
Link list CSE ( Data structure ) .
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
2CPP17 - File IO
2CPP17 - File IO2CPP17 - File IO
2CPP17 - File IO
 

Ähnlich wie Single linked list

–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdfpasqualealvarez467
 
I am not able to complete the last function. Could anyone please hel.pdf
I am not able to complete the last function. Could anyone please hel.pdfI am not able to complete the last function. Could anyone please hel.pdf
I am not able to complete the last function. Could anyone please hel.pdffantoosh1
 
Linked List Implementation of Queue in C
Linked List Implementation of Queue in CLinked List Implementation of Queue in C
Linked List Implementation of Queue in CKasun Ranga Wijeweera
 
Linked lists - Exercises
Linked lists - ExercisesLinked lists - Exercises
Linked lists - ExercisesEleonora Ciceri
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribdAmit Kapoor
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Please solve the TODO parts of the following probelm incl.pdf
Please solve the TODO parts of the following probelm  incl.pdfPlease solve the TODO parts of the following probelm  incl.pdf
Please solve the TODO parts of the following probelm incl.pdfaggarwalopticalsco
 
Effective C#
Effective C#Effective C#
Effective C#lantoli
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklistilsamaryum
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdfanupambedcovers
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docxnoreendchesterton753
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptkinan keshkeh
 

Ähnlich wie Single linked list (20)

–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
 
I am not able to complete the last function. Could anyone please hel.pdf
I am not able to complete the last function. Could anyone please hel.pdfI am not able to complete the last function. Could anyone please hel.pdf
I am not able to complete the last function. Could anyone please hel.pdf
 
Linked List Implementation of Queue in C
Linked List Implementation of Queue in CLinked List Implementation of Queue in C
Linked List Implementation of Queue in C
 
Linked lists - Exercises
Linked lists - ExercisesLinked lists - Exercises
Linked lists - Exercises
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Linked lists
Linked listsLinked lists
Linked lists
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
C programming
C programmingC programming
C programming
 
Please solve the TODO parts of the following probelm incl.pdf
Please solve the TODO parts of the following probelm  incl.pdfPlease solve the TODO parts of the following probelm  incl.pdf
Please solve the TODO parts of the following probelm incl.pdf
 
Effective C#
Effective C#Effective C#
Effective C#
 
Dsprograms(2nd cse)
Dsprograms(2nd cse)Dsprograms(2nd cse)
Dsprograms(2nd cse)
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdf
 
Nbvtalkatbzaonencryptionpuzzles
NbvtalkatbzaonencryptionpuzzlesNbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
 
Nbvtalkatbzaonencryptionpuzzles
NbvtalkatbzaonencryptionpuzzlesNbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
 
Write code in c++ Program to a topological sort on a graph Program pl.docx
Write code in c++ Program to a topological sort on a graph  Program pl.docxWrite code in c++ Program to a topological sort on a graph  Program pl.docx
Write code in c++ Program to a topological sort on a graph Program pl.docx
 
Shapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop conceptShapes and calculate (area and contour) / C++ oop concept
Shapes and calculate (area and contour) / C++ oop concept
 
Pointers
PointersPointers
Pointers
 

Kürzlich hochgeladen

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
 
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
 
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
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
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
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
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
 
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
 
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
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
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
 

Kürzlich hochgeladen (20)

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
 
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
 
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
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
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)
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
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...
 
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
 
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
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
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
 

Single linked list

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. If list is empty i.e. P==NULL P Q NULL
  • 8. If list is empty i.e. P==NULL P Q p=(struct node *) malloc(sizeof(struct node))
  • 9. If list is empty i.e. P==NULL P Q p=(struct node *) malloc(sizeof(struct node)) P->data=num 10
  • 10. If list is empty i.e. P==NULL P Q p=(struct node *) malloc(sizeof(struct node)) P->data=num 10 P->link=NULL NULL
  • 11. If list is not empty i.e. p!=NULL 10 20 30 Node A Node B Node C NULL P Q
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. If position is 1 10 20 30 Node A Node B Node C NULL Q P
  • 22. If position is 1 10 20 30 Node A Node B Node C NULL Q P p=(struct node *) malloc(sizeof(struct node));
  • 23. If position is 1 10 20 30 Node A Node B Node C NULL Q P p=(struct node *) malloc(sizeof(struct node)); p->data=num 5
  • 24. If position is 1 10 20 30 Node A Node B Node C NULL Q P p=(struct node *) malloc(sizeof(struct node)); p->data=num; 5 p->link=q;
  • 25. If position is greater than 1 10 20 30 Node A Node B Node C NULL Q P Suppose a node is to be inserted at position 3.
  • 26. 10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; }
  • 27. 10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp
  • 28. 10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp
  • 29. 10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp Node BC q->link=(struct node *) malloc(sizeof(struct node));
  • 30. 10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp Node BC q->link=(struct node *) malloc(sizeof(struct node)); 25 q->link->data=num;
  • 31. 10 20 30 Node A Node B Node C NULL P Q for(i=1;i<=3-2;i++) { q=q->link; } temp Node BC q->link=(struct node *) malloc(sizeof(struct node)); 25 q->link->data=num; q->link->link=temp;
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41. If position is 1 10 20 30 10 NULL Node A Node B Node C Node D P Q
  • 42.
  • 43. If position is 1 10 20 30 10 NULL Node A Node B Node C Node D P Q
  • 44.
  • 45.
  • 46.
  • 47.
  • 48. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 7 6 3 Node A Node B Node C 1 NULL Node D i j
  • 49. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 7 6 3 Node A Node B Node C 1 NULL Node D i j
  • 50. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 6 7 3 Node A Node B Node C 1 NULL Node D i j
  • 51. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 3 7 6 Node A Node B Node C 1 NULL Node D i j
  • 52. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 3 7 6 Node A Node B Node C 1 NULL Node D i j
  • 53. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 1 7 6 Node A Node B Node C 3 NULL Node D i j
  • 54. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 1 6 7 Node A Node B Node C 3 NULL Node D i j
  • 55. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 1 3 7 Node A Node B Node C 6 NULL Node D i j
  • 56. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 1 3 7 Node A Node B Node C 6 NULL Node D i j
  • 57. SORTING Traversal & comparison: for(i=p;i!=NULL;i=i->link) { for(j=i->link;j!=NULL;j=j->link) { if(i->data>j->data) { temp=i->data; i->data=j->data; j->data=temp; } } } 1 3 6 Node A Node B Node C 7 NULL Node D i j
  • 58.