SlideShare a Scribd company logo
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
Ad

Recommended

PPTX
Difference Between AI(Artificial Intelligence), ML(Machine Learning), DL (Dee...
International Institute of Information Technology (I²IT)
 
PPTX
Introduction to Big Data, HADOOP: HDFS, MapReduce
International Institute of Information Technology (I²IT)
 
PPTX
Adapter Pattern: Introduction & Implementation (with examples)
International Institute of Information Technology (I²IT)
 
PPTX
Engineering Mathematics | Maxima and Minima
International Institute of Information Technology (I²IT)
 
PPTX
Conformal Mapping - Introduction & Examples
International Institute of Information Technology (I²IT)
 
PPTX
Cloud Computing & Virtual Infrastructure
International Institute of Information Technology (I²IT)
 
PPTX
Artificial Intelligence - Introduction
International Institute of Information Technology (I²IT)
 
PPTX
State Pattern: Introduction & Implementation
International Institute of Information Technology (I²IT)
 
PPTX
Introduction to TCP Protocol Suite
International Institute of Information Technology (I²IT)
 
PPTX
What are the real differences between a wireframe, storyboard and a prototype?
International Institute of Information Technology (I²IT)
 
PPTX
Usability Heuristics - Principles & Examples
International Institute of Information Technology (I²IT)
 
PPTX
Introduction To Assembly Language Programming
International Institute of Information Technology (I²IT)
 
PPTX
Types of Artificial Intelligence
International Institute of Information Technology (I²IT)
 
PPTX
Superstructure and it's various components
International Institute of Information Technology (I²IT)
 
PPTX
Factor Analysis & The Measurement Model
International Institute of Information Technology (I²IT)
 
PPTX
Supervised Learning in Cybersecurity
International Institute of Information Technology (I²IT)
 
PPTX
FUSION - Pattern Recognition, Classification, Classifier Fusion
International Institute of Information Technology (I²IT)
 
PPTX
Human Computer Interaction - INPUT OUTPUT CHANNELS
International Institute of Information Technology (I²IT)
 
PPTX
Differential Equation - Order Degree
International Institute of Information Technology (I²IT)
 
PPTX
What Is High Performance-Computing?
International Institute of Information Technology (I²IT)
 
PPTX
Fundamentals of Computer Networks
International Institute of Information Technology (I²IT)
 

More Related Content

What's hot (20)

PPTX
Artificial Intelligence - Introduction
International Institute of Information Technology (I²IT)
 
PPTX
State Pattern: Introduction & Implementation
International Institute of Information Technology (I²IT)
 
PPTX
Introduction to TCP Protocol Suite
International Institute of Information Technology (I²IT)
 
PPTX
What are the real differences between a wireframe, storyboard and a prototype?
International Institute of Information Technology (I²IT)
 
PPTX
Usability Heuristics - Principles & Examples
International Institute of Information Technology (I²IT)
 
PPTX
Introduction To Assembly Language Programming
International Institute of Information Technology (I²IT)
 
PPTX
Types of Artificial Intelligence
International Institute of Information Technology (I²IT)
 
PPTX
Superstructure and it's various components
International Institute of Information Technology (I²IT)
 
PPTX
Factor Analysis & The Measurement Model
International Institute of Information Technology (I²IT)
 
PPTX
Supervised Learning in Cybersecurity
International Institute of Information Technology (I²IT)
 
PPTX
FUSION - Pattern Recognition, Classification, Classifier Fusion
International Institute of Information Technology (I²IT)
 
PPTX
Human Computer Interaction - INPUT OUTPUT CHANNELS
International Institute of Information Technology (I²IT)
 
PPTX
Differential Equation - Order Degree
International Institute of Information Technology (I²IT)
 
Artificial Intelligence - Introduction
International Institute of Information Technology (I²IT)
 
State Pattern: Introduction & Implementation
International Institute of Information Technology (I²IT)
 
What are the real differences between a wireframe, storyboard and a prototype?
International Institute of Information Technology (I²IT)
 
Usability Heuristics - Principles & Examples
International Institute of Information Technology (I²IT)
 
Introduction To Assembly Language Programming
International Institute of Information Technology (I²IT)
 
Superstructure and it's various components
International Institute of Information Technology (I²IT)
 
Factor Analysis & The Measurement Model
International Institute of Information Technology (I²IT)
 
Supervised Learning in Cybersecurity
International Institute of Information Technology (I²IT)
 
FUSION - Pattern Recognition, Classification, Classifier Fusion
International Institute of Information Technology (I²IT)
 
Human Computer Interaction - INPUT OUTPUT CHANNELS
International Institute of Information Technology (I²IT)
 
Differential Equation - Order Degree
International Institute of Information Technology (I²IT)
 

Similar to Data Structure - Linked List (20)

PPTX
What Is High Performance-Computing?
International Institute of Information Technology (I²IT)
 
PPTX
Fundamentals of Computer Networks
International Institute of Information Technology (I²IT)
 
PDF
The Overview of Discovery and Reconciliation of LTE Network
IRJET Journal
 
PDF
IRJET- Intelligence Extraction using Various Machine Learning Algorithms
IRJET Journal
 
PPTX
Systems Programming & Operating Systems - Overview of LEX-and-YACC
International Institute of Information Technology (I²IT)
 
PPTX
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
DOCX
PROJECT FOR CSE BY TUSHAR DHOOT
Tushar Dhoot
 
PDF
Data and File Structure Lecture Notes
FellowBuddy.com
 
PDF
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
IJDKP
 
PDF
IRJET- Intelligent Laboratory Management System based on Internet of Thin...
IRJET Journal
 
PDF
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
IRJET Journal
 
PPT
devops dtail education and devops ools which r used
bhagirath bhatt
 
PPTX
Introduction to Wireless Sensor Networks (WSN)
International Institute of Information Technology (I²IT)
 
PPTX
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
PDF
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
IJCSEA Journal
 
PDF
IRJET- E-Attendance Manager: A Review
IRJET Journal
 
The Overview of Discovery and Reconciliation of LTE Network
IRJET Journal
 
IRJET- Intelligence Extraction using Various Machine Learning Algorithms
IRJET Journal
 
Systems Programming & Operating Systems - Overview of LEX-and-YACC
International Institute of Information Technology (I²IT)
 
DAA Introduction to Algorithms & Application
International Institute of Information Technology (I²IT)
 
PROJECT FOR CSE BY TUSHAR DHOOT
Tushar Dhoot
 
Data and File Structure Lecture Notes
FellowBuddy.com
 
WEB-BASED DATA MINING TOOLS : PERFORMING FEEDBACK ANALYSIS AND ASSOCIATION RU...
IJDKP
 
IRJET- Intelligent Laboratory Management System based on Internet of Thin...
IRJET Journal
 
IRJET- Analysis for EnhancedForecastof Expense Movement in Stock Exchange
IRJET Journal
 
devops dtail education and devops ools which r used
bhagirath bhatt
 
Introduction to Wireless Sensor Networks (WSN)
International Institute of Information Technology (I²IT)
 
Understanding Natural Language Processing
International Institute of Information Technology (I²IT)
 
HIGH SPEED DATA RETRIEVAL FROM NATIONAL DATA CENTER (NDC) REDUCING TIME AND I...
IJCSEA Journal
 
IRJET- E-Attendance Manager: A Review
IRJET Journal
 
Ad

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

PPTX
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
International Institute of Information Technology (I²IT)
 
PPTX
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
PPTX
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
PPTX
Servlet: A Server-side Technology
International Institute of Information Technology (I²IT)
 
PPTX
What Is Jenkins? Features and How It Works
International Institute of Information Technology (I²IT)
 
PPTX
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
PPTX
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
PPT
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
PPT
Java as Object Oriented Programming Language
International Institute of Information Technology (I²IT)
 
PPTX
Data Visualization - How to connect Microsoft Forms to Power BI
International Institute of Information Technology (I²IT)
 
PPTX
Yoga To Fight & Win Against COVID-19
International Institute of Information Technology (I²IT)
 
Professional Ethics & Etiquette: What Are They & How Do I Get Them?
International Institute of Information Technology (I²IT)
 
Writing Skills: Importance of Writing Skills
International Institute of Information Technology (I²IT)
 
Professional Communication | Introducing Oneself
International Institute of Information Technology (I²IT)
 
What Is Jenkins? Features and How It Works
International Institute of Information Technology (I²IT)
 
Data Science, Big Data, Data Analytics
International Institute of Information Technology (I²IT)
 
Sentiment Analysis in Machine Learning
International Institute of Information Technology (I²IT)
 
Importance of Theory of Computations
International Institute of Information Technology (I²IT)
 
Java as Object Oriented Programming Language
International Institute of Information Technology (I²IT)
 
Data Visualization - How to connect Microsoft Forms to Power BI
International Institute of Information Technology (I²IT)
 
Yoga To Fight & Win Against COVID-19
International Institute of Information Technology (I²IT)
 
Ad

Recently uploaded (20)

PDF
Complete University of Calculus :: 2nd edition
Shabista Imam
 
PPTX
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
PDF
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
PPTX
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
PDF
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
PPTX
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
PPTX
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
PDF
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
PDF
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
PPTX
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
PPTX
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PDF
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
PDF
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Mark Billinghurst
 
PPTX
Bitumen Emulsion by Dr Sangita Ex CRRI Delhi
grilcodes
 
PPTX
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PDF
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
PPTX
Structural Wonderers_new and ancient.pptx
nikopapa113
 
Complete University of Calculus :: 2nd edition
Shabista Imam
 
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Mark Billinghurst
 
Bitumen Emulsion by Dr Sangita Ex CRRI Delhi
grilcodes
 
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Structural Wonderers_new and ancient.pptx
nikopapa113
 

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