SlideShare a Scribd company logo
Linked List
What are the problems with Arrays
- Size is fixed
-Array Items are stored contiguously
-Insertions and deletion at particular position is complex
Why Linked list ?
-Size is not fixed
-Data can be stored at any place
-Insertions and deletions are simple and faster
What is Linked List?
A linked list is a collection of nodes with various fields
It contains data field and Address field or Link field
Info field
Link Field/
Address Field
Pointer to the
first node
Linked List Types
Singly Linked list
Circular singly linked list
Doubly linked lists
Circular doubly linked lists
Graphical Representation
10
1000
1000
2000
200015 NULL20
4000
Singly Linked List
First
Graphical Representation
10
1000
1000
2000
200015 400020
4000
Circular Singly Linked List
Last node contains the address of the first node
First
Doubly Linked list
Contains the address of previous node
and next node
NULL
2000 30001000
10 15 202000 1000 2000 NULL3000
First
Circular Doubly Linked list
Contains the address of first node and
last node
3000
2000 30001000
10 15 202000 1000 2000 10003000
First
Representation of Singly Linked list
struct node
{
int info;
struct node *link
};
typedef struct node *NODE;
Meaning of this: A node is of the type struct and
contains info field and link filed
What is typedef ?
typedef is a keyword in the C Language used to give
the new name to data types
The intent is to make it easier for programmers
Example typedef int x;
Later on you can use x as a data type
x a, b;
Means a and b are variables of the type integer
Graphical Representation
10
1000
1000
2000
200015 NULL20
4000
Operations on Singly Linked List
First
Insert
Delete
Display the contents
Allocation of memory to newnode
newnode =( NODE ) malloc (sizeof(struct node));
It Returns address of the location with piece of
memory of the size struct. That is for information
field and address field
Algorithm to Insert an Element from the front
1 temp=allocate memory
2 temp(info)=item;
3 link(temp)=first;
4 call temp as first
5 temp <- newnode
6 return first;
temp
30
Temp node with item
NULL
NULL NULL
10
1000
1000
2000
200015 NULL20
4000
Operations on Singly Linked List
Insert from the front
First
temp
temp->link=first,
10
1000
1000
2000
200015 NULL20
4000
Operations on Singly Linked List
Insert from the front
First
first=temp
Algorithm to Display the content
// Algorithm Display
if (first==NULL)
write list empty
return;
Write “ Contents of the List ”
temp=first
While(temp!=NULL)
{
write (info(temp))
temp=link(temp)
C Function to Insert an Element from
the front
Insertfront(NODE first int item)
{
NODE temp;
temp=(NODE) malloc(sizeof(struct node));
temp->info=item;
temp->link=NULL ;
temp->link=first;
first=temp;
return(temp);
}
Algorithm to Delete from the front
1 if (first==NULL)
2 Write list empty and return first
3 temp=first
4 first=link(first)
5 free(temp)
6 return(first)
C Function to Delete the element from the
front
NODE deletefront(NODE first)
{
if (first==NULL)
{ printf(List is empty..n”);
return first;
}
temp=first;
first=first->link;
printf(“ The ietm deleted is %d”,temp->info);
free(temp);
return(first);
}
10
1000
1000
2000
200015 NULL20
4000
Operations on Singly Linked List
Delete from the front
Temp/
First
temp=first
10
1000
1000
2000
200015 NULL20
4000
Operations on Singly Linked List
Delete from the front
First
temp
temp=first, first=first->link
1000 2000
200015 NULL20
Operations on Singly Linked List
Delete from the front
First

More Related Content

What's hot

Array implementation and linked list as datat structure
Array implementation and linked list as datat structureArray implementation and linked list as datat structure
Array implementation and linked list as datat structure
Tushar Aneyrao
 
Linked list
Linked listLinked list
Linked list
VONI
 

What's hot (20)

linked list
linked listlinked list
linked list
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
Linked lists
Linked listsLinked lists
Linked lists
 
Linked list
Linked listLinked list
Linked list
 
Link list
Link listLink list
Link list
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Deletion from single way linked list and search
Deletion from single way linked list and searchDeletion from single way linked list and search
Deletion from single way linked list and search
 
List
ListList
List
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
linked list
linked list linked list
linked list
 
Array implementation and linked list as datat structure
Array implementation and linked list as datat structureArray implementation and linked list as datat structure
Array implementation and linked list as datat structure
 
Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)
 
Linked list
Linked listLinked list
Linked list
 
linked list using c
linked list using clinked list using c
linked list using c
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
 

Similar to Linkedlist1

dokumen.tips_linked-list-ppt-5584a44be6115.pptx
dokumen.tips_linked-list-ppt-5584a44be6115.pptxdokumen.tips_linked-list-ppt-5584a44be6115.pptx
dokumen.tips_linked-list-ppt-5584a44be6115.pptx
MrMudassir
 

Similar to Linkedlist1 (20)

dokumen.tips_linked-list-ppt-5584a44be6115.pptx
dokumen.tips_linked-list-ppt-5584a44be6115.pptxdokumen.tips_linked-list-ppt-5584a44be6115.pptx
dokumen.tips_linked-list-ppt-5584a44be6115.pptx
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
LINKED LIST.pptx
LINKED LIST.pptxLINKED LIST.pptx
LINKED LIST.pptx
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
3.ppt
3.ppt3.ppt
3.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
03-Lists.ppt
03-Lists.ppt03-Lists.ppt
03-Lists.ppt
 
Module 3 Dara structure notes
Module 3 Dara structure notesModule 3 Dara structure notes
Module 3 Dara structure notes
 
Data structure
Data structureData structure
Data structure
 
Linked list traversal
Linked list traversalLinked list traversal
Linked list traversal
 
Array linked list.ppt
Array  linked list.pptArray  linked list.ppt
Array linked list.ppt
 
Data structure
Data structureData structure
Data structure
 
What is a singly linked list- What is a doubly linked list- What is a.docx
What is a singly linked list- What is a doubly linked list- What is a.docxWhat is a singly linked list- What is a doubly linked list- What is a.docx
What is a singly linked list- What is a doubly linked list- What is a.docx
 
LINKED LIST IN C++ +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
LINKED LIST IN C++ +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSLINKED LIST IN C++ +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
LINKED LIST IN C++ +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdf
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 
Linked list
Linked listLinked list
Linked list
 
linked-list.ppt
linked-list.pptlinked-list.ppt
linked-list.ppt
 
linked list
linked list linked list
linked list
 
Data Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptxData Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptx
 

More from Rajendran

More from Rajendran (20)

Element distinctness lower bounds
Element distinctness lower boundsElement distinctness lower bounds
Element distinctness lower bounds
 
Scheduling with Startup and Holding Costs
Scheduling with Startup and Holding CostsScheduling with Startup and Holding Costs
Scheduling with Startup and Holding Costs
 
Divide and conquer surfing lower bounds
Divide and conquer  surfing lower boundsDivide and conquer  surfing lower bounds
Divide and conquer surfing lower bounds
 
Red black tree
Red black treeRed black tree
Red black tree
 
Hash table
Hash tableHash table
Hash table
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Proof master theorem
Proof master theoremProof master theorem
Proof master theorem
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Recurrence theorem
Recurrence theoremRecurrence theorem
Recurrence theorem
 
Master method
Master method Master method
Master method
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Hash tables
Hash tablesHash tables
Hash tables
 
Lower bound
Lower boundLower bound
Lower bound
 
Master method theorem
Master method theoremMaster method theorem
Master method theorem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Longest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm AnalysisLongest common subsequences in Algorithm Analysis
Longest common subsequences in Algorithm Analysis
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
 
Average case Analysis of Quicksort
Average case Analysis of QuicksortAverage case Analysis of Quicksort
Average case Analysis of Quicksort
 
Np completeness
Np completenessNp completeness
Np completeness
 
computer languages
computer languagescomputer languages
computer languages
 

Recently uploaded

Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
YibeltalNibretu
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 

Linkedlist1