SlideShare une entreprise Scribd logo
1  sur  23
L I N K E D L IST
       Dr. S. Lovelyn Rose
       PSG College of Technology
SINGLY LINKED LIST
                   DATA         ADDRESS



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



DOUBLY LINKED LIST

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


  Previous node            Data part                     Next node
Start   ID   Name   Desig   Address
                            of Node2


        ID   Name   Desig   Address of
                            Node 3


        ID   Name   Desig   NULL
Start   NULL         Data 1   Address of
                                Node 2


        Address of   Data 2   Address of
          Node 1                Node 3

        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”);
}
 Download the file from
http://www.slideshare.net/lovelynrose/linked-list-17752737

Also visit my blogs :

  http://datastructuresinterview.blogspot.in/

  http://talkcoimbatore.blogspot.in/

  http://simpletechnical.blogspot.in/

Contenu connexe

Tendances

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
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithmTakatoshi Kondo
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212Mahmoud Samir Fayed
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2Technopark
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency명신 김
 
Modern C++ Concurrency API
Modern C++ Concurrency APIModern C++ Concurrency API
Modern C++ Concurrency APISeok-joon Yun
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingPrudhviVuda
 
C++ extension methods
C++ extension methodsC++ extension methods
C++ extension methodsphil_nash
 
Short intro to the Rust language
Short intro to the Rust languageShort intro to the Rust language
Short intro to the Rust languageGines Espada
 
Lesson 01 A Warmup Problem
Lesson 01 A Warmup ProblemLesson 01 A Warmup Problem
Lesson 01 A Warmup ProblemMitchell Wand
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"OdessaJS Conf
 
The Ring programming language version 1.6 book - Part 22 of 189
The Ring programming language version 1.6 book - Part 22 of 189The Ring programming language version 1.6 book - Part 22 of 189
The Ring programming language version 1.6 book - Part 22 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 13 of 84
The Ring programming language version 1.2 book - Part 13 of 84The Ring programming language version 1.2 book - Part 13 of 84
The Ring programming language version 1.2 book - Part 13 of 84Mahmoud Samir Fayed
 

Tendances (20)

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
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithm
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency
 
Modern C++ Concurrency API
Modern C++ Concurrency APIModern C++ Concurrency API
Modern C++ Concurrency API
 
Snake.c
Snake.cSnake.c
Snake.c
 
week-13x
week-13xweek-13x
week-13x
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
C++ extension methods
C++ extension methodsC++ extension methods
C++ extension methods
 
Short intro to the Rust language
Short intro to the Rust languageShort intro to the Rust language
Short intro to the Rust language
 
Lesson 01 A Warmup Problem
Lesson 01 A Warmup ProblemLesson 01 A Warmup Problem
Lesson 01 A Warmup Problem
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
C sharp 8
C sharp 8C sharp 8
C sharp 8
 
c programming
c programmingc programming
c programming
 
Cquestions
Cquestions Cquestions
Cquestions
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
The Ring programming language version 1.6 book - Part 22 of 189
The Ring programming language version 1.6 book - Part 22 of 189The Ring programming language version 1.6 book - Part 22 of 189
The Ring programming language version 1.6 book - Part 22 of 189
 
The Ring programming language version 1.2 book - Part 13 of 84
The Ring programming language version 1.2 book - Part 13 of 84The Ring programming language version 1.2 book - Part 13 of 84
The Ring programming language version 1.2 book - Part 13 of 84
 

En vedette

Car Parking System (Singly linked list )
Car Parking System (Singly linked list ) Car Parking System (Singly linked list )
Car Parking System (Singly linked list ) S. M. Shakib Limon
 
Data Structure Lecture 6
Data Structure Lecture 6Data Structure Lecture 6
Data Structure Lecture 6Teksify
 
Circular linked list
Circular linked listCircular linked list
Circular linked listdchuynh
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked listsstudent
 

En vedette (13)

linked list
linked list linked list
linked list
 
Linked List
Linked ListLinked List
Linked List
 
Link list
Link listLink list
Link list
 
Singly linked lists
Singly linked listsSingly linked lists
Singly linked lists
 
LINKED LISTS
LINKED LISTSLINKED LISTS
LINKED LISTS
 
Car Parking System (Singly linked list )
Car Parking System (Singly linked list ) Car Parking System (Singly linked list )
Car Parking System (Singly linked list )
 
Data Structure Lecture 6
Data Structure Lecture 6Data Structure Lecture 6
Data Structure Lecture 6
 
Team 10
Team 10Team 10
Team 10
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
De lab manual
De lab manualDe lab manual
De lab manual
 
Linked list
Linked listLinked list
Linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked lists
 

Similaire à Linked list without animation

#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 structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptxSajalFayyaz
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxMeghaKulkarni27
 
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
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
I will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdf
I will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdfI will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdf
I will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdffunkybabyindia
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
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
 
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
 
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
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of listElavarasi K
 
C++ Program to Implement Singly Linked List #includeiostream.pdf
 C++ Program to Implement Singly Linked List #includeiostream.pdf C++ Program to Implement Singly Linked List #includeiostream.pdf
C++ Program to Implement Singly Linked List #includeiostream.pdfangelsfashion1
 
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
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPGFrankDin1
 

Similaire à Linked list without animation (20)

#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 structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
 
5. Summing Series.pptx
5. Summing Series.pptx5. Summing Series.pptx
5. Summing Series.pptx
 
Insertion operation
Insertion operationInsertion operation
Insertion operation
 
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
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
I will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdf
I will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdfI will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdf
I will provide my LinkedList from my last lab.LinkedList.cpp~~~~.pdf
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
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
 
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
 
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
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
C++ Program to Implement Singly Linked List #includeiostream.pdf
 C++ Program to Implement Singly Linked List #includeiostream.pdf C++ Program to Implement Singly Linked List #includeiostream.pdf
C++ Program to Implement Singly Linked List #includeiostream.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
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 

Dernier

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 

Dernier (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 

Linked list without animation

  • 1. L I N K E D L IST Dr. S. Lovelyn Rose PSG College of Technology
  • 2. SINGLY LINKED LIST DATA ADDRESS Data 1 Data 2 . . . . . . Data n ADDRESS DOUBLY LINKED LIST ADDRESS Data 1 Data 2 . . . . . Data n ADDRESS Previous node Data part Next node
  • 3. Start ID Name Desig Address of Node2 ID Name Desig Address of Node 3 ID Name Desig NULL
  • 4. Start NULL Data 1 Address of Node 2 Address of Data 2 Address of Node 1 Node 3 Address of Data 3 Node 2 NULL
  • 5.  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
  • 6. struct node { int x; x c[10] next char c[10]; struct node *next; }*current;
  • 7. 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
  • 8. 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
  • 9. Number of nodes Allocation Insert_N_Nodes(N) and { Assignment Start=current=create_node(); Start, current 011 ABI HR NULL
  • 10. 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
  • 11. 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; }
  • 12. 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
  • 13. 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’
  • 14.  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)
  • 15. { 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
  • 16. 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
  • 17. 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
  • 18. 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
  • 19. Start 50 else { temp1->next=temp->next; temp1 20 temp->next=null; break; temp 10 } } Any node temp1=temp; 40 temp=temp->next; } }
  • 20. 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
  • 21. 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 }
  • 22. 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”); }
  • 23.  Download the file from http://www.slideshare.net/lovelynrose/linked-list-17752737 Also visit my blogs : http://datastructuresinterview.blogspot.in/ http://talkcoimbatore.blogspot.in/ http://simpletechnical.blogspot.in/