SlideShare a Scribd company logo
1 of 18
DATA STRUCTURE - LINKED LIST
Prof. Prashant J. Gadakh
Computer Engineering
International Institute of Information Technology, I²IT
www.isquareit.edu.in
Contents
• Comparison of sequential and linked organizations
• Primitive operations
• Realization of Linked Lists
• Realization of linked list using arrays
• Dynamic Memory Management
• Linked list using dynamic memory management
• Linked List Abstract Data Type
• Linked list operations
• Head pointer and header node,
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Array and Linked List
 Both are linear data structure.
 Linked lists and arrays are similar since they both
store collections of data.
 Arrays and linked lists are examples of linear lists.
 Linear lists are those in which each member has a
unique successor. Arrays contain consecutive
memory locations whereas linked lists do not
necessarily contain consecutive memory locations.
These data items can be stored anywhere in the
memory in a scattered manner.
 Array is Sequential organization whereas linked lists
is linked organization.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Array
• An array is the data structure that contains a
collection of similar type data elements and It is better
and convenient way of storing the data of same data
type with same size.
• It allocates memory in contiguous memory locations
for its elements.
• Iterating the arrays using their index is faster
compared to any other methods like linked list etc.
• It allows to store the elements in any dimensional
array - supports multidimensional array. Arrays can be
used to implement matrices.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Sequential organization
The features of this organization are the following:
1. Successive elements of a list are stored a fixed distance
apart.
2. It provides static allocation, which means, the space
allocation done by a compiler once cannot be changed
during execution, and the size has to be known in
advance.
3. As individual objects are stored a fixed distance apart,
we can access any element randomly.
4. Insertion and deletion of objects in between the list
require a lot of data movement.
5. It is space inefficient for large objects with frequent
insertions and deletions.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Linked organization
The features of this organization are the following:
1. Elements can be placed anywhere in the memory.
2. Dynamic allocation (size need not be known in
advance), that is, space allocation as per need can be
done during execution.
3. As objects are not placed in consecutive locations at a
fixed distance apart, random access to elements is
not possible.
4. Insertion and deletion of objects do not require any
data shifting.
5. Linked organization needs the use of pointers and
dynamic memory allocation.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Linked List
Advantages of Linked Lists
1. They are a dynamic in nature which allocates the memory when
required.
2. Insertion and deletion operations can be easily implemented.
3. Stacks and queues can be easily executed.
4. Linked List reduces the access time.
Disadvantages of Linked Lists
1. The memory is wasted as pointers require extra memory for
storage.
2. No element can be accessed randomly; it has to access each node
sequentially.
3. Reverse Traversing is difficult in linked list.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Introduction of Linked List
 A linked list is an ordered collection of data in which each element
(node) contains a
minimum of two values, data and link(s).
 In a linked list, before adding any element to the list, a memory
space for that node must be allocated.
 A link is made from each item to the next item in the list.
Each node of the linked list has at least the following two
elements:
1. The data member(s) being stored in the list.
2. A pointer or link to the next element in the list.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Linked List Primitive Operations
Primitive operations
1. Creating an empty list
2. Inserting a node
3. Deleting a node
4. Traversing the list
Some more operations,
1. Searching a node
2. Updating a node
3. Printing the node or list
4. Counting the length of the list
5. Reversing the list
6. Sorting the list using pointer
manipulation
7. Concatenating two lists
8. Merging two sorted lists into a third
sorted list
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Realization of Linked List Using
Arrays
We can list all the members in the
sequence. The link value of the last
element is set to -1 to represent the end
of the list.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Dynamic Memory Management
The process of allocating memory at run-time is known as
dynamic memory allocation.
The memory space allocated between
stack and permanent storage area
regions is available for dynamic
allocation during the execution of the
program. This free memory region is
called the heap. The size of the heap
keeps changing when a program is
executed because of the creation and
deletion of the variables that are local to
the functions and blocks.
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Dynamic Memory Management
Dynamic Memory Management in C++ with new and delete
Operators. The heap is a pool of memory from which the new operator
allocates memory. The memory allocated from the system heap using
the new operator is de-allocated (released) using the delete operator.
New Operator
MyType *ptr;
ptr = new MyType;
These statements create a new dynamic object of the type MyType of
the proper size and return a pointer of the type specified to the right of
the operator new, that is, MyType *.
Syntax
Pointer_Type_Variable = new Data_Type;
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Types of Linked List
There are different implementations of Linked List
available, they are:
1. Singly Linked List
2. Doubly Linked List
3. Circular Linked List
4. Generalized Linked List
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Single Linked List
The following terms are commonly used in discussions
about linked lists:
• Header node
• Data Node
• Tail Node
Fig. A linked list of days in a week
a b c d
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Single Linked List
First node (Head)
Last node (Tail)
head
next next next next
NULL1020 1080 2020
1020 1080 020
why we need to
store the location of
the next node?
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
What is Empty List?
Empty Linked list is a single
pointer having the value of
NULL.
head = NULL;
struct Node
{
int element;
Node *next;
};
class Node
{
public :
int data;
Node *link;
};
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
How to Create Node?
Following are the 3
steps to create the
node.
1. Create node
temp= (struct Node*)
malloc (sizeof (struct
Node));
2. put the
data temp->data =
element;
3. Make next of temp
node as NULL
Create the single node.
temp= (struct Node*) malloc (sizeof (struct Node));
temp->data = element;
temp->next = NULL;
P=temp;
Create more than one node.
for (i=2; i<=n; i++)
{
printf(“enter node no %d”, i);
scanf(“%d”, &element);
temp= (struct Node*) malloc (sizeof (struct Node));
temp->data = element;
temp->next = NULL;
P->next = temp;
P=P->next;
}
International Institute of Information
Technology, I²IT, P-14, Rajiv Gandhi
Infotech Park, Hinjawadi Phase 1, Pune -
411 057
Phone - +91 20 22933441/2/3 | Website -
Thank You
www.isquareit.edu.in

More Related Content

What's hot

What's hot (20)

Document Type Definition (DTD)
Document Type Definition (DTD)Document Type Definition (DTD)
Document Type Definition (DTD)
 
Artificial Intelligence - Introduction
Artificial Intelligence - IntroductionArtificial Intelligence - Introduction
Artificial Intelligence - Introduction
 
State Pattern: Introduction & Implementation
State Pattern: Introduction  & Implementation State Pattern: Introduction  & Implementation
State Pattern: Introduction & Implementation
 
Introduction to TCP Protocol Suite
Introduction to TCP Protocol SuiteIntroduction to TCP Protocol Suite
Introduction to TCP Protocol Suite
 
Database Query Optimization
Database Query OptimizationDatabase Query Optimization
Database Query Optimization
 
What are the real differences between a wireframe, storyboard and a prototype?
What are the real differences between a wireframe, storyboard and a prototype?What are the real differences between a wireframe, storyboard and a prototype?
What are the real differences between a wireframe, storyboard and a prototype?
 
Usability Heuristics - Principles & Examples
Usability Heuristics - Principles & ExamplesUsability Heuristics - Principles & Examples
Usability Heuristics - Principles & Examples
 
Introduction To Assembly Language Programming
Introduction To Assembly Language ProgrammingIntroduction To Assembly Language Programming
Introduction To Assembly Language Programming
 
What is DevOps?
What is DevOps?What is DevOps?
What is DevOps?
 
Types of Artificial Intelligence
Types of Artificial Intelligence Types of Artificial Intelligence
Types of Artificial Intelligence
 
What Is Cascading Style Sheet?
What Is Cascading Style Sheet?What Is Cascading Style Sheet?
What Is Cascading Style Sheet?
 
Interrupt Handling with LPC2148
Interrupt Handling with LPC2148Interrupt Handling with LPC2148
Interrupt Handling with LPC2148
 
Superstructure and it's various components
Superstructure and it's various componentsSuperstructure and it's various components
Superstructure and it's various components
 
Factor Analysis & The Measurement Model
Factor Analysis & The Measurement Model Factor Analysis & The Measurement Model
Factor Analysis & The Measurement Model
 
Supervised Learning in Cybersecurity
Supervised Learning in CybersecuritySupervised Learning in Cybersecurity
Supervised Learning in Cybersecurity
 
Basics of Business Management
Basics of Business ManagementBasics of Business Management
Basics of Business Management
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
FUSION - Pattern Recognition, Classification, Classifier Fusion
FUSION - Pattern Recognition, Classification, Classifier Fusion FUSION - Pattern Recognition, Classification, Classifier Fusion
FUSION - Pattern Recognition, Classification, Classifier Fusion
 
Human Computer Interaction - INPUT OUTPUT CHANNELS
Human Computer Interaction - INPUT OUTPUT CHANNELSHuman Computer Interaction - INPUT OUTPUT CHANNELS
Human Computer Interaction - INPUT OUTPUT CHANNELS
 
Differential Equation - Order Degree
Differential Equation - Order DegreeDifferential Equation - Order Degree
Differential Equation - Order Degree
 

Similar to Data Structure - Linked List

The Overview of Discovery and Reconciliation of LTE Network
The Overview of Discovery and Reconciliation of LTE NetworkThe Overview of Discovery and Reconciliation of LTE Network
The Overview of Discovery and Reconciliation of LTE NetworkIRJET Journal
 
IRJET- Intelligence Extraction using Various Machine Learning Algorithms
IRJET- Intelligence Extraction using Various Machine Learning AlgorithmsIRJET- Intelligence Extraction using Various Machine Learning Algorithms
IRJET- Intelligence Extraction using Various Machine Learning AlgorithmsIRJET Journal
 
PROJECT FOR CSE BY TUSHAR DHOOT
PROJECT FOR CSE BY TUSHAR DHOOTPROJECT FOR CSE BY TUSHAR DHOOT
PROJECT FOR CSE BY TUSHAR DHOOTTushar Dhoot
 
Data and File Structure Lecture Notes
Data and File Structure Lecture NotesData and File Structure Lecture Notes
Data and File Structure Lecture NotesFellowBuddy.com
 
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...IJDKP
 
IRJET- Intelligent Laboratory Management System based on Internet of Thin...
IRJET-  	  Intelligent Laboratory Management System based on Internet of Thin...IRJET-  	  Intelligent Laboratory Management System based on Internet of Thin...
IRJET- Intelligent Laboratory Management System based on Internet of Thin...IRJET Journal
 
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock ExchangeIRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock ExchangeIRJET Journal
 
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...IJCSEA Journal
 
IRJET- E-Attendance Manager: A Review
IRJET-  	  E-Attendance Manager: A ReviewIRJET-  	  E-Attendance Manager: A Review
IRJET- E-Attendance Manager: A ReviewIRJET Journal
 

Similar to Data Structure - Linked List (20)

What Is High Performance-Computing?
What Is High Performance-Computing?What Is High Performance-Computing?
What Is High Performance-Computing?
 
Fundamentals of Computer Networks
Fundamentals of Computer NetworksFundamentals of Computer Networks
Fundamentals of Computer Networks
 
Big Data Technologies
Big Data TechnologiesBig Data Technologies
Big Data Technologies
 
COA | Memory Organization
COA | Memory Organization COA | Memory Organization
COA | Memory Organization
 
File Handling in Python
File Handling in PythonFile Handling in Python
File Handling in Python
 
The Overview of Discovery and Reconciliation of LTE Network
The Overview of Discovery and Reconciliation of LTE NetworkThe Overview of Discovery and Reconciliation of LTE Network
The Overview of Discovery and Reconciliation of LTE Network
 
IRJET- Intelligence Extraction using Various Machine Learning Algorithms
IRJET- Intelligence Extraction using Various Machine Learning AlgorithmsIRJET- Intelligence Extraction using Various Machine Learning Algorithms
IRJET- Intelligence Extraction using Various Machine Learning Algorithms
 
Systems Programming & Operating Systems - Overview of LEX-and-YACC
Systems Programming & Operating Systems - Overview of LEX-and-YACCSystems Programming & Operating Systems - Overview of LEX-and-YACC
Systems Programming & Operating Systems - Overview of LEX-and-YACC
 
DAA Introduction to Algorithms & Application
DAA Introduction to Algorithms & ApplicationDAA Introduction to Algorithms & Application
DAA Introduction to Algorithms & Application
 
PROJECT FOR CSE BY TUSHAR DHOOT
PROJECT FOR CSE BY TUSHAR DHOOTPROJECT FOR CSE BY TUSHAR DHOOT
PROJECT FOR CSE BY TUSHAR DHOOT
 
Data and File Structure Lecture Notes
Data and File Structure Lecture NotesData and File Structure Lecture Notes
Data and File Structure Lecture Notes
 
Red Black Tree (and Examples)
Red Black Tree (and Examples)Red Black Tree (and Examples)
Red Black Tree (and Examples)
 
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
 
IRJET- Intelligent Laboratory Management System based on Internet of Thin...
IRJET-  	  Intelligent Laboratory Management System based on Internet of Thin...IRJET-  	  Intelligent Laboratory Management System based on Internet of Thin...
IRJET- Intelligent Laboratory Management System based on Internet of Thin...
 
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock ExchangeIRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
 
Introduction to Wireless Sensor Networks (WSN)
Introduction to Wireless Sensor Networks (WSN)Introduction to Wireless Sensor Networks (WSN)
Introduction to Wireless Sensor Networks (WSN)
 
Understanding Natural Language Processing
Understanding Natural Language ProcessingUnderstanding Natural Language Processing
Understanding Natural Language Processing
 
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
 
IRJET- E-Attendance Manager: A Review
IRJET-  	  E-Attendance Manager: A ReviewIRJET-  	  E-Attendance Manager: A Review
IRJET- E-Attendance Manager: A Review
 
Programming with LEX & YACC
Programming with LEX & YACCProgramming with LEX & YACC
Programming with LEX & YACC
 

More from International Institute of Information Technology (I²IT)

More from International Institute of Information Technology (I²IT) (20)

Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
What Is Smart Computing?
What Is Smart Computing?What Is Smart Computing?
What Is Smart Computing?
 
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
Professional Ethics & Etiquette: What Are They & How Do I Get Them?Professional Ethics & Etiquette: What Are They & How Do I Get Them?
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
 
Writing Skills: Importance of Writing Skills
Writing Skills: Importance of Writing SkillsWriting Skills: Importance of Writing Skills
Writing Skills: Importance of Writing Skills
 
Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself Professional Communication | Introducing Oneself
Professional Communication | Introducing Oneself
 
Servlet: A Server-side Technology
Servlet: A Server-side TechnologyServlet: A Server-side Technology
Servlet: A Server-side Technology
 
What Is Jenkins? Features and How It Works
What Is Jenkins? Features and How It WorksWhat Is Jenkins? Features and How It Works
What Is Jenkins? Features and How It Works
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Hypothesis-Testing
Hypothesis-TestingHypothesis-Testing
Hypothesis-Testing
 
Data Science, Big Data, Data Analytics
Data Science, Big Data, Data AnalyticsData Science, Big Data, Data Analytics
Data Science, Big Data, Data Analytics
 
Sentiment Analysis in Machine Learning
Sentiment Analysis in  Machine LearningSentiment Analysis in  Machine Learning
Sentiment Analysis in Machine Learning
 
What Is Cloud Computing?
What Is Cloud Computing?What Is Cloud Computing?
What Is Cloud Computing?
 
Introduction To Design Pattern
Introduction To Design PatternIntroduction To Design Pattern
Introduction To Design Pattern
 
Importance of Theory of Computations
Importance of Theory of ComputationsImportance of Theory of Computations
Importance of Theory of Computations
 
Java as Object Oriented Programming Language
Java as Object Oriented Programming LanguageJava as Object Oriented Programming Language
Java as Object Oriented Programming Language
 
Data Visualization - How to connect Microsoft Forms to Power BI
Data Visualization - How to connect Microsoft Forms to Power BIData Visualization - How to connect Microsoft Forms to Power BI
Data Visualization - How to connect Microsoft Forms to Power BI
 
AVL Tree Explained
AVL Tree ExplainedAVL Tree Explained
AVL Tree Explained
 
Yoga To Fight & Win Against COVID-19
Yoga To Fight & Win Against COVID-19Yoga To Fight & Win Against COVID-19
Yoga To Fight & Win Against COVID-19
 
LR(0) PARSER
LR(0) PARSERLR(0) PARSER
LR(0) PARSER
 
Land Pollution - Causes, Effects & Solution
Land Pollution - Causes, Effects & SolutionLand Pollution - Causes, Effects & Solution
Land Pollution - Causes, Effects & Solution
 

Recently uploaded

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 

Data Structure - Linked List

  • 1. DATA STRUCTURE - LINKED LIST Prof. Prashant J. Gadakh Computer Engineering International Institute of Information Technology, I²IT www.isquareit.edu.in
  • 2. Contents • Comparison of sequential and linked organizations • Primitive operations • Realization of Linked Lists • Realization of linked list using arrays • Dynamic Memory Management • Linked list using dynamic memory management • Linked List Abstract Data Type • Linked list operations • Head pointer and header node, International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website -
  • 3. Array and Linked List  Both are linear data structure.  Linked lists and arrays are similar since they both store collections of data.  Arrays and linked lists are examples of linear lists.  Linear lists are those in which each member has a unique successor. Arrays contain consecutive memory locations whereas linked lists do not necessarily contain consecutive memory locations. These data items can be stored anywhere in the memory in a scattered manner.  Array is Sequential organization whereas linked lists is linked organization. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website -
  • 4. Array • An array is the data structure that contains a collection of similar type data elements and It is better and convenient way of storing the data of same data type with same size. • It allocates memory in contiguous memory locations for its elements. • Iterating the arrays using their index is faster compared to any other methods like linked list etc. • It allows to store the elements in any dimensional array - supports multidimensional array. Arrays can be used to implement matrices. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website -
  • 5. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Sequential organization The features of this organization are the following: 1. Successive elements of a list are stored a fixed distance apart. 2. It provides static allocation, which means, the space allocation done by a compiler once cannot be changed during execution, and the size has to be known in advance. 3. As individual objects are stored a fixed distance apart, we can access any element randomly. 4. Insertion and deletion of objects in between the list require a lot of data movement. 5. It is space inefficient for large objects with frequent insertions and deletions.
  • 6. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Linked organization The features of this organization are the following: 1. Elements can be placed anywhere in the memory. 2. Dynamic allocation (size need not be known in advance), that is, space allocation as per need can be done during execution. 3. As objects are not placed in consecutive locations at a fixed distance apart, random access to elements is not possible. 4. Insertion and deletion of objects do not require any data shifting. 5. Linked organization needs the use of pointers and dynamic memory allocation.
  • 7. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Linked List Advantages of Linked Lists 1. They are a dynamic in nature which allocates the memory when required. 2. Insertion and deletion operations can be easily implemented. 3. Stacks and queues can be easily executed. 4. Linked List reduces the access time. Disadvantages of Linked Lists 1. The memory is wasted as pointers require extra memory for storage. 2. No element can be accessed randomly; it has to access each node sequentially. 3. Reverse Traversing is difficult in linked list.
  • 8. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Introduction of Linked List  A linked list is an ordered collection of data in which each element (node) contains a minimum of two values, data and link(s).  In a linked list, before adding any element to the list, a memory space for that node must be allocated.  A link is made from each item to the next item in the list. Each node of the linked list has at least the following two elements: 1. The data member(s) being stored in the list. 2. A pointer or link to the next element in the list.
  • 9. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Linked List Primitive Operations Primitive operations 1. Creating an empty list 2. Inserting a node 3. Deleting a node 4. Traversing the list Some more operations, 1. Searching a node 2. Updating a node 3. Printing the node or list 4. Counting the length of the list 5. Reversing the list 6. Sorting the list using pointer manipulation 7. Concatenating two lists 8. Merging two sorted lists into a third sorted list
  • 10. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Realization of Linked List Using Arrays We can list all the members in the sequence. The link value of the last element is set to -1 to represent the end of the list.
  • 11. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Dynamic Memory Management The process of allocating memory at run-time is known as dynamic memory allocation. The memory space allocated between stack and permanent storage area regions is available for dynamic allocation during the execution of the program. This free memory region is called the heap. The size of the heap keeps changing when a program is executed because of the creation and deletion of the variables that are local to the functions and blocks.
  • 12. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Dynamic Memory Management Dynamic Memory Management in C++ with new and delete Operators. The heap is a pool of memory from which the new operator allocates memory. The memory allocated from the system heap using the new operator is de-allocated (released) using the delete operator. New Operator MyType *ptr; ptr = new MyType; These statements create a new dynamic object of the type MyType of the proper size and return a pointer of the type specified to the right of the operator new, that is, MyType *. Syntax Pointer_Type_Variable = new Data_Type;
  • 13. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Types of Linked List There are different implementations of Linked List available, they are: 1. Singly Linked List 2. Doubly Linked List 3. Circular Linked List 4. Generalized Linked List
  • 14. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Single Linked List The following terms are commonly used in discussions about linked lists: • Header node • Data Node • Tail Node Fig. A linked list of days in a week
  • 15. a b c d International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Single Linked List First node (Head) Last node (Tail) head next next next next NULL1020 1080 2020 1020 1080 020 why we need to store the location of the next node?
  • 16. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - What is Empty List? Empty Linked list is a single pointer having the value of NULL. head = NULL; struct Node { int element; Node *next; }; class Node { public : int data; Node *link; };
  • 17. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - How to Create Node? Following are the 3 steps to create the node. 1. Create node temp= (struct Node*) malloc (sizeof (struct Node)); 2. put the data temp->data = element; 3. Make next of temp node as NULL Create the single node. temp= (struct Node*) malloc (sizeof (struct Node)); temp->data = element; temp->next = NULL; P=temp; Create more than one node. for (i=2; i<=n; i++) { printf(“enter node no %d”, i); scanf(“%d”, &element); temp= (struct Node*) malloc (sizeof (struct Node)); temp->data = element; temp->next = NULL; P->next = temp; P=P->next; }
  • 18. International Institute of Information Technology, I²IT, P-14, Rajiv Gandhi Infotech Park, Hinjawadi Phase 1, Pune - 411 057 Phone - +91 20 22933441/2/3 | Website - Thank You www.isquareit.edu.in