SlideShare a Scribd company logo
2
Most read
8
Most read
17
Most read
Linked list using Dynamic Memory Allocation
Linked list
• A linked list is a data structure which is a sequence of nodes in
which each node is linked, or connected to, the node following it.
Each node element is called node.
In this figure store two thing :-
 An element of the list.
 A link or address of the other node.
Type of Linked List
There are 4 type of linked list such as:-
• Singly-linked list
• Doubly linked list
• Circular linked list
• Circular doubly linked list.
Operation of linked list
There are some operation to be performed on the
liked lists are as follows:-
• Creation
• Insertion
• Deletion
• traversing
• Searching
• concatenation
• Display.
Singly linked list
• A singly linked list is dynamic data structure. It may grow or shrink. Growing or shrinking
depends on the operations made.
• In ‘c’ a linked list is created using structure , pointer and dynamic memory allocation
function malloc(). We consider head as external pointer.
Creating a node:-
struct node {
Int data;
Node*next;
}
start;
Start=NULL;
Implementation of Linked List.
• Insertion of a node at the beginning
• Insertion of a node at the end
• Insertion of a node after a specified node
• Deletion of a particular node from the list
• Traversing of entire link list.
Inserting a node at beginning
• Algorithm:-
1) Insert_first(Start, item)
[Check the overflow]
if ptr=NULL, then
Print “overflow
Exit
else
Ptr=(node*)malloc(size of node));
End if
2) Set ptr->Info=item
3) Set ptr->next=start
4) Set start=ptr
Inserting a node at the end
Insert _last(Start , item)
1) [check over flow?]
if ptr=NULL, then
print ”over flow”
exit
else
ptr=(node*)malloc(sizeOf(node));
end if
2) Set ptr->info=item
3) Set ptr->next=NULL
4) If start=NULL and if then set start=p;
5) loc=start
6) Repeate step 7 until loc->next!=NULL
7) Loc=loc->next
8) Loc->next=p
Insertion at the specified position
C code:-
void insert_spe(int item, int loc){
NODE *p,*temp;
int k;
for(k=0;temp=start;k<loc;k++)
{
temp=temp->next;
If(temp==NULL){
printf(“node in the list at less than onen”);
return;
}
}
p=(NODE*)malloc(sizeof(NODE));
p->info=item;
p->next=loc->next;
loc->next=p;
}
Doubly Linked list
• In double linked list, every node has link to its previous
node and next node.
we can traverse forward by using next field and can traverse
backward by using previous field. Every node in a double
linked list contains three fields and they are shown in the
following figure...
Doubly Linked list…continue..
Structure definition Doubly linked list:-
struct node
{
int num;
struct node*prev;
struct node*node;
};
typedef struct node NODE;
Circular linked list
• Circular linked list is a sequence of elements in which every
element has link to its next element in the sequence and the
last element has a link to the first element in the sequence.
• There is no NULL at the end.
• A circular linked list can be a singly circular linked list or
doubly circular linked list.
Circular linked list… continue..
• The structure definition of the circular linked.:-
struct node
{
int info;
struct node *next;
};
typedef struct node *NODEPTR;
Circular Doubly Linked list
• Circular Doubly Linked List has properties of both doubly
linked list and circular linked list
• In which two consecutive elements are linked or connected
by previous and next pointer.
• And the last node points to first node by next pointer and also
the first node points to last node by previous pointer
Circular doubly linked list….. Conti..
•
typedef struct _dslist_node 3
{
int node_value; /* Data value */
struct _dslist_node * prev; /* pointer to previous node
*/
struct _dslist_node * next; /* pointer to next node */
}
dslist_node;
Advantages
• List can be traversed bothways from head to tail as well as tail
to head
• Being a circular linked list tail can be reached with one
operation from head node
Disadvantages
• It takes slightly extra memory in each node to accomodate
previous pointer
Practical Applications
• Managing songs playlist in media player applications
• Managing shopping cart in online shopping
Linked list using Dynamic Memory Allocation

More Related Content

PPTX
Binary Search Tree
PPTX
Linked list
PPT
1.1 binary tree
PPTX
linked list in Data Structure, Simple and Easy Tutorial
PPTX
Introduction to data structure ppt
PPTX
Linked List - Insertion & Deletion
PPTX
Binary Tree in Data Structure
PPTX
Linked List
Binary Search Tree
Linked list
1.1 binary tree
linked list in Data Structure, Simple and Easy Tutorial
Introduction to data structure ppt
Linked List - Insertion & Deletion
Binary Tree in Data Structure
Linked List

What's hot (20)

PPTX
Data Structures (CS8391)
PPTX
Threaded Binary Tree.pptx
PPTX
Linked list in Data Structure and Algorithm
PPT
Binary tree
PPTX
Binary Search Tree in Data Structure
PPT
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
PPTX
Arrays in Data Structure and Algorithm
PPTX
Bubble Sort Algorithm Presentation
PPTX
Data structures and algorithms
PPTX
PPTX
Doubly Linked List
PDF
Red black tree
PPTX
Linked list
PPTX
linked list in data structure
PPT
One Dimensional Array
PPT
Singly link list
PPT
Bubble sort
PPTX
PPTX
Binary search in data structure
Data Structures (CS8391)
Threaded Binary Tree.pptx
Linked list in Data Structure and Algorithm
Binary tree
Binary Search Tree in Data Structure
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
Arrays in Data Structure and Algorithm
Bubble Sort Algorithm Presentation
Data structures and algorithms
Doubly Linked List
Red black tree
Linked list
linked list in data structure
One Dimensional Array
Singly link list
Bubble sort
Binary search in data structure
Ad

Similar to Linked list using Dynamic Memory Allocation (20)

PDF
DS Module 03.pdf
PPTX
Linked List in Data Structure
PPTX
Deleting a node from the list(SINGLE LINKED LIST)
PPTX
Linked Lists, Single Linked list and its operations
PPTX
circularlinklist-190205164051.pptx
PPTX
Circular link list.ppt
PPTX
Data structure
PPTX
Ll.pptx
PPTX
linked list.pptx
DOCX
Linked list.docx
PPTX
Doubly & Circular Linked Lists
ODP
Linked List
PPT
Link list using array in Data structure amd algorithms
PPTX
Linked lists linked lists vs Arrays.pptx
PPTX
DATA STRUCTURES AND LINKED LISTS IN C.pptx
PPTX
DATA STRUCTURES AND LINKED LISTS IN C.pptx
PPT
ANOITO2341988888888888888888888885555.ppt
PDF
Circular linked list
PDF
Document on Linked List as a presentation
DS Module 03.pdf
Linked List in Data Structure
Deleting a node from the list(SINGLE LINKED LIST)
Linked Lists, Single Linked list and its operations
circularlinklist-190205164051.pptx
Circular link list.ppt
Data structure
Ll.pptx
linked list.pptx
Linked list.docx
Doubly & Circular Linked Lists
Linked List
Link list using array in Data structure amd algorithms
Linked lists linked lists vs Arrays.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
ANOITO2341988888888888888888888885555.ppt
Circular linked list
Document on Linked List as a presentation
Ad

More from kiran Patel (11)

PPTX
2017 Union budget of India
PPTX
C++ concept of Polymorphism
PPTX
Database Management System( Normalization)
PPTX
B tree (computer Science)
PPTX
Effort estimation( software Engineering)
PPTX
Thread (Operating System)
PPTX
Library management (use case diagram Software engineering)
PPTX
Brain Computer Interface
PPTX
Artificial Inteligence
PPTX
Smart buckets ppt
PPTX
Dynamic memory Allocation in c language
2017 Union budget of India
C++ concept of Polymorphism
Database Management System( Normalization)
B tree (computer Science)
Effort estimation( software Engineering)
Thread (Operating System)
Library management (use case diagram Software engineering)
Brain Computer Interface
Artificial Inteligence
Smart buckets ppt
Dynamic memory Allocation in c language

Recently uploaded (20)

PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
System and Network Administration Chapter 2
PDF
System and Network Administraation Chapter 3
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Nekopoi APK 2025 free lastest update
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
top salesforce developer skills in 2025.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
medical staffing services at VALiNTRY
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Understanding Forklifts - TECH EHS Solution
How Creative Agencies Leverage Project Management Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
System and Network Administration Chapter 2
System and Network Administraation Chapter 3
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Nekopoi APK 2025 free lastest update
Design an Analysis of Algorithms II-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
top salesforce developer skills in 2025.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Adobe Illustrator 28.6 Crack My Vision of Vector Design
medical staffing services at VALiNTRY
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Understanding Forklifts - TECH EHS Solution

Linked list using Dynamic Memory Allocation

  • 2. Linked list • A linked list is a data structure which is a sequence of nodes in which each node is linked, or connected to, the node following it. Each node element is called node. In this figure store two thing :-  An element of the list.  A link or address of the other node.
  • 3. Type of Linked List There are 4 type of linked list such as:- • Singly-linked list • Doubly linked list • Circular linked list • Circular doubly linked list.
  • 4. Operation of linked list There are some operation to be performed on the liked lists are as follows:- • Creation • Insertion • Deletion • traversing • Searching • concatenation • Display.
  • 5. Singly linked list • A singly linked list is dynamic data structure. It may grow or shrink. Growing or shrinking depends on the operations made. • In ‘c’ a linked list is created using structure , pointer and dynamic memory allocation function malloc(). We consider head as external pointer. Creating a node:- struct node { Int data; Node*next; } start; Start=NULL;
  • 6. Implementation of Linked List. • Insertion of a node at the beginning • Insertion of a node at the end • Insertion of a node after a specified node • Deletion of a particular node from the list • Traversing of entire link list.
  • 7. Inserting a node at beginning • Algorithm:- 1) Insert_first(Start, item) [Check the overflow] if ptr=NULL, then Print “overflow Exit else Ptr=(node*)malloc(size of node)); End if 2) Set ptr->Info=item 3) Set ptr->next=start 4) Set start=ptr
  • 8. Inserting a node at the end Insert _last(Start , item) 1) [check over flow?] if ptr=NULL, then print ”over flow” exit else ptr=(node*)malloc(sizeOf(node)); end if 2) Set ptr->info=item 3) Set ptr->next=NULL 4) If start=NULL and if then set start=p; 5) loc=start 6) Repeate step 7 until loc->next!=NULL 7) Loc=loc->next 8) Loc->next=p
  • 9. Insertion at the specified position C code:- void insert_spe(int item, int loc){ NODE *p,*temp; int k; for(k=0;temp=start;k<loc;k++) { temp=temp->next; If(temp==NULL){ printf(“node in the list at less than onen”); return; } } p=(NODE*)malloc(sizeof(NODE)); p->info=item; p->next=loc->next; loc->next=p; }
  • 10. Doubly Linked list • In double linked list, every node has link to its previous node and next node. we can traverse forward by using next field and can traverse backward by using previous field. Every node in a double linked list contains three fields and they are shown in the following figure...
  • 11. Doubly Linked list…continue.. Structure definition Doubly linked list:- struct node { int num; struct node*prev; struct node*node; }; typedef struct node NODE;
  • 12. Circular linked list • Circular linked list is a sequence of elements in which every element has link to its next element in the sequence and the last element has a link to the first element in the sequence. • There is no NULL at the end. • A circular linked list can be a singly circular linked list or doubly circular linked list.
  • 13. Circular linked list… continue.. • The structure definition of the circular linked.:- struct node { int info; struct node *next; }; typedef struct node *NODEPTR;
  • 14. Circular Doubly Linked list • Circular Doubly Linked List has properties of both doubly linked list and circular linked list • In which two consecutive elements are linked or connected by previous and next pointer. • And the last node points to first node by next pointer and also the first node points to last node by previous pointer
  • 15. Circular doubly linked list….. Conti.. • typedef struct _dslist_node 3 { int node_value; /* Data value */ struct _dslist_node * prev; /* pointer to previous node */ struct _dslist_node * next; /* pointer to next node */ } dslist_node;
  • 16. Advantages • List can be traversed bothways from head to tail as well as tail to head • Being a circular linked list tail can be reached with one operation from head node Disadvantages • It takes slightly extra memory in each node to accomodate previous pointer Practical Applications • Managing songs playlist in media player applications • Managing shopping cart in online shopping