SlideShare una empresa de Scribd logo
1 de 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/

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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
 

Último

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Último (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 

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/