SlideShare a Scribd company logo
2
Most read
Introduction to Linked List
Advantages and Disadvantages of Arrays
Advantages of array implementation:
• The elements are faster to access using random access.
• Searching an element is easier.
Limitation of array implementation
• The number of elements in the array is fixed.
• Insertion and deletion operation in array are expensive.
• Memory is allocated at compile time i.e static memory allocation.
Linked list
• Linked list is an ordered collection of elements which are connected by
links/pointers.
• Memory is allocated at run time i.e. dynamic memory allocation.
• New elements can be stored anywhere in the memory (non contiguous memory
location)
• Each node contains two fields namely,
• Data field-The data field contains the actual data of the elements to be stored in
the list.
• Next field- Address of the next data items.
Linked list representation
data next data next data null
HEAD
Data Next
5 10 15
Head Node
Node •Data field-The data
field contains the actual
data of the elements to
be stored in the list.
•Next field- Address of
the next data items.
Types of Linked List
• Singly Linked List
• Doubly Linked List
• Circular Linked List
Singly Linked list
5 1000 10 2000 15
Head Node
1000 2000
A singly linked list is a linked list in which each node contains only one
link field pointing to the next node in the list.
Singly Linked list with Header
• The header node is at the very beginning of the linked list.
• It is an extra node kept at the front of a list.
• Does not represent an item in the linked list.
• It contains the address of the first node.
5 1000 10 2000 15
Header
node
1000
Operations on SLL
Basic operations on a singly-linked list are:
◦ Insert – Inserts a new node in the list.
◦ Delete – Deletes any node from the list.
◦ Display-display the date in the list
◦ Search-find whether a element is present in the list or not
Singly Linked List - Structure Definition
struct node
{
int data;
struct node * next;
};
Next
Data
Size of this Structure:
For Integer: 4 bytes
For Pointer : 4 Bytes
Totally : 8 bytes
malloc()
malloc()
The malloc function reserves a block of memory of specified size and returns a
pointer (starting address of the memory block).
The general syntax of malloc() is
ptr =(cast-type*)malloc(byte-size);
Example:
newnode=(struct node*)malloc(sizeof(struct node));
malloc()
newnode=(struct node*)malloc(sizeof(struct node));
8 bytes
newnode 
8 bytes of memory
will be allocated

More Related Content

PDF
Set methods in python
PPTX
Strings in Python
PPTX
Queue in Data Structure
PPTX
Queue_Data_Structure.pptx
PPT
Stacks
PPTX
Unit 3 stack
PPTX
Circular linked list
PDF
Expression trees
Set methods in python
Strings in Python
Queue in Data Structure
Queue_Data_Structure.pptx
Stacks
Unit 3 stack
Circular linked list
Expression trees

What's hot (20)

PDF
Python set
PPSX
Data Structure (Queue)
PDF
Python list
PPTX
Ppt on Linked list,stack,queue
PDF
linked lists in data structures
PPTX
Data Structures - Lecture 8 [Sorting Algorithms]
PPTX
Doubly Linked List
PPT
PPT
Linked list
PDF
Strings in Python
PPTX
Data structure and its types
PPTX
Application of Data structure
PPSX
PPTX
PPTX
Stack and Queue
PPTX
linked list in data structure
PPTX
PPTX
PPTX
Linked list
PPTX
queue & its applications
Python set
Data Structure (Queue)
Python list
Ppt on Linked list,stack,queue
linked lists in data structures
Data Structures - Lecture 8 [Sorting Algorithms]
Doubly Linked List
Linked list
Strings in Python
Data structure and its types
Application of Data structure
Stack and Queue
linked list in data structure
Linked list
queue & its applications
Ad

Similar to Linked list (20)

PPTX
Linked lists linked lists vs Arrays.pptx
PDF
ds-lecture-4-171012041008 (1).pdf
PPTX
Linked list (1).pptx
PPT
lecture 02.2.ppt
PPTX
linked_list.pptx
PPTX
data structures and applications power p
PPTX
module 3-.pptx
PPTX
ALGORITHM ANALYSIS AND LISTS ABSTACTS DT
PPTX
Linked list
PPT
ANOITO2341988888888888888888888885555.ppt
PPTX
Data Structures_Linear data structures Linked Lists.pptx
PPTX
Introduction to Data Structures and Linked List
PPT
Unit 1 linked list
PPTX
Lecture ............ 3 - Linked Lists.pptx
PPTX
Data Structures-UNIT Four_Linked_List.pptx
PPTX
Linked Lists, Single Linked list and its operations
PPTX
DLL DATA STRUCT.pptx
PDF
Data Structure Lecture 3 Linked Lists.pdf
PPTX
Linked list using Dynamic Memory Allocation
PPTX
Data Structure and Algorithms by Sabeen Memon03.pptx
Linked lists linked lists vs Arrays.pptx
ds-lecture-4-171012041008 (1).pdf
Linked list (1).pptx
lecture 02.2.ppt
linked_list.pptx
data structures and applications power p
module 3-.pptx
ALGORITHM ANALYSIS AND LISTS ABSTACTS DT
Linked list
ANOITO2341988888888888888888888885555.ppt
Data Structures_Linear data structures Linked Lists.pptx
Introduction to Data Structures and Linked List
Unit 1 linked list
Lecture ............ 3 - Linked Lists.pptx
Data Structures-UNIT Four_Linked_List.pptx
Linked Lists, Single Linked list and its operations
DLL DATA STRUCT.pptx
Data Structure Lecture 3 Linked Lists.pdf
Linked list using Dynamic Memory Allocation
Data Structure and Algorithms by Sabeen Memon03.pptx
Ad

Recently uploaded (20)

PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Basic Mud Logging Guide for educational purpose
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
RMMM.pdf make it easy to upload and study
PDF
Complications of Minimal Access Surgery at WLH
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
Institutional Correction lecture only . . .
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Renaissance Architecture: A Journey from Faith to Humanism
Basic Mud Logging Guide for educational purpose
Supply Chain Operations Speaking Notes -ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Insiders guide to clinical Medicine.pdf
PPH.pptx obstetrics and gynecology in nursing
RMMM.pdf make it easy to upload and study
Complications of Minimal Access Surgery at WLH
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
GDM (1) (1).pptx small presentation for students
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Types and Its function , kingdom of life
Institutional Correction lecture only . . .
Pharmacology of Heart Failure /Pharmacotherapy of CHF
STATICS OF THE RIGID BODIES Hibbelers.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?

Linked list

  • 2. Advantages and Disadvantages of Arrays Advantages of array implementation: • The elements are faster to access using random access. • Searching an element is easier. Limitation of array implementation • The number of elements in the array is fixed. • Insertion and deletion operation in array are expensive. • Memory is allocated at compile time i.e static memory allocation.
  • 3. Linked list • Linked list is an ordered collection of elements which are connected by links/pointers. • Memory is allocated at run time i.e. dynamic memory allocation. • New elements can be stored anywhere in the memory (non contiguous memory location) • Each node contains two fields namely, • Data field-The data field contains the actual data of the elements to be stored in the list. • Next field- Address of the next data items.
  • 4. Linked list representation data next data next data null HEAD Data Next 5 10 15 Head Node Node •Data field-The data field contains the actual data of the elements to be stored in the list. •Next field- Address of the next data items.
  • 5. Types of Linked List • Singly Linked List • Doubly Linked List • Circular Linked List
  • 6. Singly Linked list 5 1000 10 2000 15 Head Node 1000 2000 A singly linked list is a linked list in which each node contains only one link field pointing to the next node in the list.
  • 7. Singly Linked list with Header • The header node is at the very beginning of the linked list. • It is an extra node kept at the front of a list. • Does not represent an item in the linked list. • It contains the address of the first node. 5 1000 10 2000 15 Header node 1000
  • 8. Operations on SLL Basic operations on a singly-linked list are: ◦ Insert – Inserts a new node in the list. ◦ Delete – Deletes any node from the list. ◦ Display-display the date in the list ◦ Search-find whether a element is present in the list or not
  • 9. Singly Linked List - Structure Definition struct node { int data; struct node * next; }; Next Data Size of this Structure: For Integer: 4 bytes For Pointer : 4 Bytes Totally : 8 bytes
  • 10. malloc() malloc() The malloc function reserves a block of memory of specified size and returns a pointer (starting address of the memory block). The general syntax of malloc() is ptr =(cast-type*)malloc(byte-size); Example: newnode=(struct node*)malloc(sizeof(struct node));
  • 11. malloc() newnode=(struct node*)malloc(sizeof(struct node)); 8 bytes newnode  8 bytes of memory will be allocated