SlideShare une entreprise Scribd logo
1  sur  21
L I N K E D L IST
  (Download file to view animation)

               Dr. S. Lovelyn Rose
               PSG College of Technology
               Coimbatore, India
SINGLY LINKED LIST
                    DATA         ADDRESS



                Data 1 Data 2 . . . . . . Data n    ADDRESS



DOUBLY LINKED LIST
                ID                 Name     Desig Address
        Start
                                                  of Node2
     ADDRESS      Data 1 Data 2 . . . . . Data n ADDRESS
     Start         NULL               Data 1     Address of
                         ID     Name Desig        Address of
                                                   Node 2
                                                  Node 3
  Previous node             Data part                  Next node
                   Address of         Data 2         Address of
                     NodeID1       Name Desig         NULL 3
                                                       Node

                   Address of           Data 3
                     Node 2                            NULL
 CIRCULAR LINKED LIST
          SINGLY
  Start



          Data 1    Node 2       Data 2   Node 3            Data 3     Node1
              Node 1                  Node 2                    Node 3
          DOUBLY
  Start



Node3     Data 1    Node 2   Node 1   Data 1   Node 3

           Node 1                     Node 2       Node 2     Data 1     Node1

                                                              Node 3
struct node
{
  int x;
                     x   c[10]   next
   char c[10];
struct node *next;
}*current;
create_node()
{
  current=(struct node *)malloc(sizeof(struct node));
  current->x=10; current->c=“try”; current->next=null;
  return current;
}
Allocation               x    c[10]     next



Assignment                10    try     NULL
Create a linked list for maintaining the employee details
  such as Ename,Eid,Edesig.
Steps:
1)Identify the node structure struct node
                                 {
2)Allocate space for the node
                                   int Eid;
3)Insert the node in the list      char Ename[10],Edesig[10];
                                     struct node *next;
                                  } *current;



     EID        EName        EDesig          next
Number of nodes
                                      Allocation
Insert_N_Nodes(N)
                                      and
{                                     Assignment
  Start=current=create_node();
 Start,
current

            011     ABI          HR         NULL
for(i=1;i<n-1;i++)
  {
      current->next=create_node();
      current=current->next;
} }
  Start,
 current

             011       ABI           HR


     i=1     012       Banu      DBA      NULL
start


Insert()
{                      10     c
  c=create_node();
  start=c;
                       20     c1
  c1=create_node();
  c->next=c1;
  c2=create_node();    30     c2
  c1->next=c2;
}
Start
                        20                        30
Insert_a_node(Start)
{                              Start
current= create_node();                     10
current->next=Start;                             20
Start=current;
}                                current               30

                                 10
Note : Passing Start as a parameter implies the list already exists
Start


   10            20             30             40



                         25
Steps:
1)Have a pointer (slow) to the node after which the new
  node is to be inserted
2)Create the new node to be inserted and store the address
  in ‘current’
3) Adjust the pointers of ‘slow’ and ‘current’
 Use two pointers namely, fast and slow
 Move the ‘slow’ pointer by one element in the list
 For every single movement of ‘slow’, move ‘fast’ by 2
  elements
 When ‘fast’ points to the last element, ‘slow’ would be
  pointing to the middle element
 This required moving through the list only once
 So the middle element is found in a time complexity of
  O(n)
{
current=(struct node *)malloc(sizeof(struct node))
fast=slow=Start                    Start          10
do
                                                 fast slow
{
  if(fast->next->next!=null)                      20
        fast=fast->next->next     current
  else break;
  slow=slow->next                25               30
}while(fast->next!=null)
current->next=slow->next
slow->next=current                                40
}
Note : fast and slow are below the node they point to
Insert_last(Start)
{                               Start   10
  current=Start;
  while(current->next!=null)
                                        20
  {
      current=current->next;
  }                           temp
                                        30
  temp=create_node();        25
  current->next=temp;
}                                       40
delete_node(start,x)
{
  temp=start;
  temp1=temp;
  while(temp!=null)     Last node
  {
  if(temp->n==x)                      start
  {               Only one node
  if(temp==start && temp->next==null)         10
       start=null                              temp
start
else if(temp==start)
{                         First node
                                                 10           temp
  start=start->next;
  temp->next=null;
                                           20
  break;
}
                                 start
else if(temp->next==null)
                                                      temp1
{
                                                  10
  temp1->next=null;
                                                      temp
}
                                                  20

       Last node
Start                 50
else
{
  temp1->next=temp->next;              temp1        20

  temp->next=null;
  break;
                                      temp     10
}
}
                   Any node
temp1=temp;                                         40

temp=temp->next;
}
}
Inserting N nodes
Insert_node(N)          create_node()
{                       {
                        c=(struct node*)malloc(sizeof(struct
start=c=create_node();
                                                      node))
for(i=0;i<N-1;i++)             c->x;
{                              c->previous=null;
  c1=create_node();            c->next=null;
                               return c;
  c->next=c1;           }
  c1->previous=c;
}
}                      10                      20

    start              c                      c1
delete_node(start,n)
{
                                 start
temp=start
while(temp!=null)    End of list          10

{                                        temp
if(temp->x==n)
{                     single node
 if(temp==start)
{
temp->next->previous=null;
start=temp->next
}
else if(temp->next==null)                    start

 temp->previous->next=null;
else                                           20
            Last node
{
temp->next->previous=temp->previous;
                                                10
temp->previous->next=temp->next;
                                              temp
}
                     middle node              30
}
else
  temp=temp->next;
}
if(temp==null) print(“Element not found”);
}
http://datastructuresinterview.blogspot.in/

http://talkcoimbatore.blogspot.in/

http://simpletechnical.blogspot.in/

Contenu connexe

Tendances

Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticino2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticinoArnaud Bos
 
Image Recognition with Neural Network
Image Recognition with Neural NetworkImage Recognition with Neural Network
Image Recognition with Neural NetworkSajib Sen
 
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single ThreadedThe Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single ThreadedBryan Hughes
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesTeerawat Issariyakul
 
Lectia 3. aplicații greedy.
Lectia 3. aplicații greedy.Lectia 3. aplicații greedy.
Lectia 3. aplicații greedy.StefanBolohan
 
09 - Program verification
09 - Program verification09 - Program verification
09 - Program verificationTudor Girba
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor ConcurrencyAlex Miller
 
C++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersC++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersAdam Feldscher
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
Ch01 basic concepts_nosoluiton
Ch01 basic concepts_nosoluitonCh01 basic concepts_nosoluiton
Ch01 basic concepts_nosoluitonshin
 
Scale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneScale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneRoman Elizarov
 
Operational research
Operational researchOperational research
Operational researchAlbi Thomas
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2Technopark
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"OdessaJS Conf
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"OdessaJS Conf
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureanishgoel
 

Tendances (20)

Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticino2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticino
 
Image Recognition with Neural Network
Image Recognition with Neural NetworkImage Recognition with Neural Network
Image Recognition with Neural Network
 
The Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single ThreadedThe Node.js Event Loop: Not So Single Threaded
The Node.js Event Loop: Not So Single Threaded
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
 
NS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variablesNS2: Binding C++ and OTcl variables
NS2: Binding C++ and OTcl variables
 
Lectia 3. aplicații greedy.
Lectia 3. aplicații greedy.Lectia 3. aplicații greedy.
Lectia 3. aplicații greedy.
 
09 - Program verification
09 - Program verification09 - Program verification
09 - Program verification
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
Página 115
Página 115Página 115
Página 115
 
C++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersC++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime Numbers
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Ch01 basic concepts_nosoluiton
Ch01 basic concepts_nosoluitonCh01 basic concepts_nosoluiton
Ch01 basic concepts_nosoluiton
 
Scale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneScale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOne
 
Operational research
Operational researchOperational research
Operational research
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
Lecture1 classes3
Lecture1 classes3Lecture1 classes3
Lecture1 classes3
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 

En vedette

Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked listVivek Bhargav
 
Linked List data structure
Linked List data structureLinked List data structure
Linked List data structureMarcus Biel
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Lovelyn Rose
 
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
 

En vedette (13)

Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
Linked List data structure
Linked List data structureLinked List data structure
Linked List data structure
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
 
Linked list
Linked listLinked list
Linked list
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Linked lists
Linked listsLinked lists
Linked lists
 
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 list
linked list linked list
linked list
 
Link List
Link ListLink List
Link List
 
Linked list
Linked listLinked list
Linked list
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linked list
Linked listLinked list
Linked list
 
Link list
Link listLink list
Link list
 

Similaire à Linked list

data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptxSajalFayyaz
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdfharihelectronicspune
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfmail931892
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxMeghaKulkarni27
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of listElavarasi K
 
double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdffacevenky
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad balochSarmad Baloch
 
I keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdfI keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdfarkmuzikllc
 
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
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfaathiauto
 

Similaire à Linked list (20)

data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
5. Summing Series.pptx
5. Summing Series.pptx5. Summing Series.pptx
5. Summing Series.pptx
 
Insertion operation
Insertion operationInsertion operation
Insertion operation
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdf
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad baloch
 
I keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdfI keep getting NullPointerExcepetion, can someone help me with spinL.pdf
I keep getting NullPointerExcepetion, can someone help me with spinL.pdf
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
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
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
17 linkedlist (1)
17 linkedlist (1)17 linkedlist (1)
17 linkedlist (1)
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 

Dernier

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
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 

Dernier (20)

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...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

Linked list

  • 1. L I N K E D L IST (Download file to view animation) Dr. S. Lovelyn Rose PSG College of Technology Coimbatore, India
  • 2. SINGLY LINKED LIST DATA ADDRESS Data 1 Data 2 . . . . . . Data n ADDRESS DOUBLY LINKED LIST ID Name Desig Address Start of Node2 ADDRESS Data 1 Data 2 . . . . . Data n ADDRESS Start NULL Data 1 Address of ID Name Desig Address of Node 2 Node 3 Previous node Data part Next node Address of Data 2 Address of NodeID1 Name Desig NULL 3 Node Address of Data 3 Node 2 NULL
  • 3.  CIRCULAR LINKED LIST SINGLY Start Data 1 Node 2 Data 2 Node 3 Data 3 Node1 Node 1 Node 2 Node 3 DOUBLY Start Node3 Data 1 Node 2 Node 1 Data 1 Node 3 Node 1 Node 2 Node 2 Data 1 Node1 Node 3
  • 4. struct node { int x; x c[10] next char c[10]; struct node *next; }*current;
  • 5. create_node() { current=(struct node *)malloc(sizeof(struct node)); current->x=10; current->c=“try”; current->next=null; return current; } Allocation x c[10] next Assignment 10 try NULL
  • 6. Create a linked list for maintaining the employee details such as Ename,Eid,Edesig. Steps: 1)Identify the node structure struct node { 2)Allocate space for the node int Eid; 3)Insert the node in the list char Ename[10],Edesig[10]; struct node *next; } *current; EID EName EDesig next
  • 7. Number of nodes Allocation Insert_N_Nodes(N) and { Assignment Start=current=create_node(); Start, current 011 ABI HR NULL
  • 8. for(i=1;i<n-1;i++) { current->next=create_node(); current=current->next; } } Start, current 011 ABI HR i=1 012 Banu DBA NULL
  • 9. start Insert() { 10 c c=create_node(); start=c; 20 c1 c1=create_node(); c->next=c1; c2=create_node(); 30 c2 c1->next=c2; }
  • 10. Start 20 30 Insert_a_node(Start) { Start current= create_node(); 10 current->next=Start; 20 Start=current; } current 30 10 Note : Passing Start as a parameter implies the list already exists
  • 11. Start 10 20 30 40 25 Steps: 1)Have a pointer (slow) to the node after which the new node is to be inserted 2)Create the new node to be inserted and store the address in ‘current’ 3) Adjust the pointers of ‘slow’ and ‘current’
  • 12.  Use two pointers namely, fast and slow  Move the ‘slow’ pointer by one element in the list  For every single movement of ‘slow’, move ‘fast’ by 2 elements  When ‘fast’ points to the last element, ‘slow’ would be pointing to the middle element  This required moving through the list only once  So the middle element is found in a time complexity of O(n)
  • 13. { current=(struct node *)malloc(sizeof(struct node)) fast=slow=Start Start 10 do fast slow { if(fast->next->next!=null) 20 fast=fast->next->next current else break; slow=slow->next 25 30 }while(fast->next!=null) current->next=slow->next slow->next=current 40 } Note : fast and slow are below the node they point to
  • 14. Insert_last(Start) { Start 10 current=Start; while(current->next!=null) 20 { current=current->next; } temp 30 temp=create_node(); 25 current->next=temp; } 40
  • 15. delete_node(start,x) { temp=start; temp1=temp; while(temp!=null) Last node { if(temp->n==x) start { Only one node if(temp==start && temp->next==null) 10 start=null temp
  • 16. start else if(temp==start) { First node 10 temp start=start->next; temp->next=null; 20 break; } start else if(temp->next==null) temp1 { 10 temp1->next=null; temp } 20 Last node
  • 17. Start 50 else { temp1->next=temp->next; temp1 20 temp->next=null; break; temp 10 } } Any node temp1=temp; 40 temp=temp->next; } }
  • 18. Inserting N nodes Insert_node(N) create_node() { { c=(struct node*)malloc(sizeof(struct start=c=create_node(); node)) for(i=0;i<N-1;i++) c->x; { c->previous=null; c1=create_node(); c->next=null; return c; c->next=c1; } c1->previous=c; } } 10 20 start c c1
  • 19. delete_node(start,n) { start temp=start while(temp!=null) End of list 10 { temp if(temp->x==n) { single node if(temp==start) { temp->next->previous=null; start=temp->next }
  • 20. else if(temp->next==null) start temp->previous->next=null; else 20 Last node { temp->next->previous=temp->previous; 10 temp->previous->next=temp->next; temp } middle node 30 } else temp=temp->next; } if(temp==null) print(“Element not found”); }