SlideShare ist ein Scribd-Unternehmen logo
1 von 22
BIRLA INSTITUTE OF TECHNOLOGY MESRA,
JAIPUR CAMPUS
NAME :- NIKHIL AGRAWAL
ROLL NO :- MCA/25004/18
TOPIC:-LINKED LIST
Linked List
 It is a linear collection of data elements, called nodes, where the linear
order is implemented by means of pointers.
 Nodes are structures made up of data and a pointer to another node.
 Usually the pointer is called next.
NODE
 Each Node of a list is comprising of two items -
the data and a reference to the next node.
 The last node has a reference to null. The entry
point into a linked list is called the head of the
list.
 It should be noted that head is not a separate
node, but the reference to the first node.
 If the list is empty then the head is a null
reference.
Creating a Node
struct node{
int data; // A simple node of a linked list
node *next;
}*start;
start=NULL; /*start points at the first node
initialized to NULL at beginning*/
node* create( int num) //say num=1 is passed from main
{
node*ptr;
ptr= new node; //memory allocated dynamically
if(ptr==NULL)
printf(“OVERFLOW”); // no memory available
exit(1);
else
{
ptr->data=num;
ptr->next=NULL;
return ptr;
}
}
Arrays VS Linked List
TYPES OF LINKED LIST
 There are three basic types of linked lists :-
1. Singly linked list.
2. Doubly linked list.
3. Circular linked list.
SINGLY LINKED LIST
 Singly linked lists contain nodes which have a data field as well as link
field.
 Each node has only one link part.
 Each link part contains the address of the next node in the list.
 Link part of the last node contains NULL value which signifies the end
of the node.
Basic Operations on a list
 Creating a List
 Inserting an element in a list
 Deleting an element from a list
 Searching a list
 Reversing a list
Inserting the node in a SLL
 There are 3 cases here:-
 Insertion at the beginning
 Insertion at the end
 Insertion after a particular node
Deleting a node from a SLL
 There are 3 cases here:-
 Deleting the first node
 Deleting the last node
 Deleting the intermediate node
Searching a SLL
 Searching involves finding the required element in
the list.
 We can use various techniques of searching like
linear search or binary search where binary
search is more efficient in case of Arrays
 But in case of linked list since random access is
not available it would become complex to do binary
search in it.
 We can perform simple linear search traversal .
Reversing a linked list
 We can reverse a linked list by reversing the direction of the links between
2 nodes.
 We make use of 3 structure pointers say p,q,r.
 At any instant q will point to the node next to p and r will point to the
node next to q.
 For next iteration p=q and q=r.
 At the end we will change head to the last node
DOUBLY LINKED LIST
 Doubly linked list is a linked data structure that consists of a set of
sequentially linked records called nodes.
 Each node contains three fields :
:- one is data part which contain data only.
:- Two other field is links part that are point or references to the
previous or to the next node in the sequence of nodes.
 The beginning and ending nodes' previous and next links, respectively,
point to some kind of terminator, typically a null node to facilitate
traversal of the list.
 Can be traversed in either direction.
 Some operations, such as deletion and inserting before a node, become easier.
Structure of DLL
struct node
{
int data;
node*next;
node*previous; //holds the address of previous node
};
INSERTING NODE IN DLL.
 Inserting at beginning
 Inserting at the end
 Inserting after a node
DELETING NODE IN DLL
CIRCULAR LINKED LIST
 Circular Linked List is a variation of Linked list in which the first
element points to the last element and the last element points to the
first element.
 Both Singly Linked List and Doubly Linked List can be made into a
circular linked list. For singly circular linked list:
In a circular linked list there are two methods
to know if a node is the first node or not.
Either a external pointer, list, points the first
node or
A header node is placed as the first node of the
circular list.
The header node can be separated from the
others by having a dedicated flag variable to
specify if the node is a header node or not.
THANK YOU.

Weitere ähnliche Inhalte

Was ist angesagt?

Circular linked list
Circular linked listCircular linked list
Circular linked list
dchuynh
 

Was ist angesagt? (20)

Linked List
Linked ListLinked List
Linked List
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
linked list
linked list linked list
linked list
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Linked list
Linked listLinked list
Linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Linked list
Linked listLinked list
Linked list
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Ppt of operations on one way link list
Ppt of operations on one way  link listPpt of operations on one way  link list
Ppt of operations on one way link list
 
single linked list
single linked listsingle linked list
single linked list
 
Link list
Link listLink list
Link list
 
Linked lists 1
Linked lists 1Linked lists 1
Linked lists 1
 

Ähnlich wie Linked List in Data Structure

Ähnlich wie Linked List in Data Structure (20)

linked list using c
linked list using clinked list using c
linked list using c
 
1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
 
Operations on linked list
Operations on linked listOperations on linked list
Operations on linked list
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
 
Linked list (1).pptx
Linked list (1).pptxLinked list (1).pptx
Linked list (1).pptx
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power p
 
lecture8 database for BSCS.................
lecture8 database for BSCS.................lecture8 database for BSCS.................
lecture8 database for BSCS.................
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
 
Linked lists
Linked listsLinked lists
Linked lists
 
csc211_lecture_21.pptx
csc211_lecture_21.pptxcsc211_lecture_21.pptx
csc211_lecture_21.pptx
 
Linked List
Linked ListLinked List
Linked List
 
data structures lists operation of lists
data structures lists operation of listsdata structures lists operation of lists
data structures lists operation of lists
 
Linked list and its operations - Traversal
Linked list and its operations - TraversalLinked list and its operations - Traversal
Linked list and its operations - Traversal
 
Linkedlists
LinkedlistsLinkedlists
Linkedlists
 
Linked list.docx
Linked list.docxLinked list.docx
Linked list.docx
 
Linked list
Linked listLinked list
Linked list
 
DLL DATA STRUCT.pptx
DLL DATA STRUCT.pptxDLL DATA STRUCT.pptx
DLL DATA STRUCT.pptx
 
Link list assi
Link list assiLink list assi
Link list assi
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 

Mehr von Meghaj Mallick

Mehr von Meghaj Mallick (20)

24 partial-orderings
24 partial-orderings24 partial-orderings
24 partial-orderings
 
PORTFOLIO BY USING HTML & CSS
PORTFOLIO BY USING HTML & CSSPORTFOLIO BY USING HTML & CSS
PORTFOLIO BY USING HTML & CSS
 
Introduction to Software Testing
Introduction to Software TestingIntroduction to Software Testing
Introduction to Software Testing
 
Introduction to System Programming
Introduction to System ProgrammingIntroduction to System Programming
Introduction to System Programming
 
MACRO ASSEBLER
MACRO ASSEBLERMACRO ASSEBLER
MACRO ASSEBLER
 
Icons, Image & Multimedia
Icons, Image & MultimediaIcons, Image & Multimedia
Icons, Image & Multimedia
 
Project Tracking & SPC
Project Tracking & SPCProject Tracking & SPC
Project Tracking & SPC
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Routing in MANET
Routing in MANETRouting in MANET
Routing in MANET
 
Macro assembler
 Macro assembler Macro assembler
Macro assembler
 
Architecture and security in Vanet PPT
Architecture and security in Vanet PPTArchitecture and security in Vanet PPT
Architecture and security in Vanet PPT
 
Design Model & User Interface Design in Software Engineering
Design Model & User Interface Design in Software EngineeringDesign Model & User Interface Design in Software Engineering
Design Model & User Interface Design in Software Engineering
 
Text Mining of Twitter in Data Mining
Text Mining of Twitter in Data MiningText Mining of Twitter in Data Mining
Text Mining of Twitter in Data Mining
 
DFS & BFS in Computer Algorithm
DFS & BFS in Computer AlgorithmDFS & BFS in Computer Algorithm
DFS & BFS in Computer Algorithm
 
Software Development Method
Software Development MethodSoftware Development Method
Software Development Method
 
Secant method in Numerical & Statistical Method
Secant method in Numerical & Statistical MethodSecant method in Numerical & Statistical Method
Secant method in Numerical & Statistical Method
 
Motivation in Organization
Motivation in OrganizationMotivation in Organization
Motivation in Organization
 
Communication Skill
Communication SkillCommunication Skill
Communication Skill
 
Partial-Orderings in Discrete Mathematics
 Partial-Orderings in Discrete Mathematics Partial-Orderings in Discrete Mathematics
Partial-Orderings in Discrete Mathematics
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 

Kürzlich hochgeladen

If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
amilabibi1
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
raffaeleoman
 

Kürzlich hochgeladen (18)

The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptx
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 

Linked List in Data Structure

  • 1. BIRLA INSTITUTE OF TECHNOLOGY MESRA, JAIPUR CAMPUS NAME :- NIKHIL AGRAWAL ROLL NO :- MCA/25004/18 TOPIC:-LINKED LIST
  • 2. Linked List  It is a linear collection of data elements, called nodes, where the linear order is implemented by means of pointers.  Nodes are structures made up of data and a pointer to another node.  Usually the pointer is called next.
  • 3. NODE  Each Node of a list is comprising of two items - the data and a reference to the next node.  The last node has a reference to null. The entry point into a linked list is called the head of the list.  It should be noted that head is not a separate node, but the reference to the first node.  If the list is empty then the head is a null reference.
  • 4. Creating a Node struct node{ int data; // A simple node of a linked list node *next; }*start; start=NULL; /*start points at the first node initialized to NULL at beginning*/
  • 5. node* create( int num) //say num=1 is passed from main { node*ptr; ptr= new node; //memory allocated dynamically if(ptr==NULL) printf(“OVERFLOW”); // no memory available exit(1); else { ptr->data=num; ptr->next=NULL; return ptr; } }
  • 7. TYPES OF LINKED LIST  There are three basic types of linked lists :- 1. Singly linked list. 2. Doubly linked list. 3. Circular linked list.
  • 8. SINGLY LINKED LIST  Singly linked lists contain nodes which have a data field as well as link field.  Each node has only one link part.  Each link part contains the address of the next node in the list.  Link part of the last node contains NULL value which signifies the end of the node.
  • 9. Basic Operations on a list  Creating a List  Inserting an element in a list  Deleting an element from a list  Searching a list  Reversing a list
  • 10. Inserting the node in a SLL  There are 3 cases here:-  Insertion at the beginning  Insertion at the end  Insertion after a particular node
  • 11. Deleting a node from a SLL  There are 3 cases here:-  Deleting the first node  Deleting the last node  Deleting the intermediate node
  • 12. Searching a SLL  Searching involves finding the required element in the list.  We can use various techniques of searching like linear search or binary search where binary search is more efficient in case of Arrays  But in case of linked list since random access is not available it would become complex to do binary search in it.  We can perform simple linear search traversal .
  • 13. Reversing a linked list  We can reverse a linked list by reversing the direction of the links between 2 nodes.  We make use of 3 structure pointers say p,q,r.  At any instant q will point to the node next to p and r will point to the node next to q.  For next iteration p=q and q=r.  At the end we will change head to the last node
  • 14. DOUBLY LINKED LIST  Doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes.  Each node contains three fields : :- one is data part which contain data only. :- Two other field is links part that are point or references to the previous or to the next node in the sequence of nodes.  The beginning and ending nodes' previous and next links, respectively, point to some kind of terminator, typically a null node to facilitate traversal of the list.
  • 15.  Can be traversed in either direction.  Some operations, such as deletion and inserting before a node, become easier.
  • 16. Structure of DLL struct node { int data; node*next; node*previous; //holds the address of previous node };
  • 17. INSERTING NODE IN DLL.  Inserting at beginning  Inserting at the end  Inserting after a node
  • 19. CIRCULAR LINKED LIST  Circular Linked List is a variation of Linked list in which the first element points to the last element and the last element points to the first element.  Both Singly Linked List and Doubly Linked List can be made into a circular linked list. For singly circular linked list:
  • 20. In a circular linked list there are two methods to know if a node is the first node or not. Either a external pointer, list, points the first node or A header node is placed as the first node of the circular list. The header node can be separated from the others by having a dedicated flag variable to specify if the node is a header node or not.
  • 21.