SlideShare a Scribd company logo
DATASTRUCTURE
DATRUCTURE IS THE WAY OF
ORGANIZING ALL DATA ITEMS IN
ORDER THAT NOT ONLY ELEMENTS
TO BE STORED BUT ALSO THE
RELATION BETWEEN THEELEMENTS
INTRODUCTION
 Data structure:-A data structure is a
logical representation of data and
operation that can be performed on
the data.
1)linear data structure
2)Non linear data structure
 Linear data structure is an order of
data elements. They are arrays,
stacks, queues, and linked lists.
Linked list :- linked list is a linear data
structure. It contains nodes. Each node
contains two parts, i.e. DATApart and
LINK part.
 The data contains elements and
 Link contains address of another node.
LIMITATIONS OF ARRAYS
 Arrays are simple to understand and
elements of an array are easily
accessible
 But arrays have some limitations.
 Arrays have a fixed dimension.
 Once the size of an array is decided it
can not be increased or decreased
during education.
 Array elements are always stored in
contiguous memory locations.
 Operations like insertion or deletion of
the array are pretty tedious.
 T
o over come this limitations we use
linked list.
LINKED LISTS
 Linked list is a collection of elements called
nodes.
 Each node contains two parts. they are
data part and link part.
Node
data link
100
200
400
• The above figure shows the example of
marks obtained by different students
can be stored in a linked list
• Here N-stands for NULL.
• Null indicates the end of the node.
14 100 30 400 42 N
WHAT ARE LINKEDLISTS
A linked list is a linear data
structure.
Nodes make up linked lists.
Nodes are structures made
up of data and a pointer to
another node.
Usually the pointer is called
next.
What is Linked List?
A linked list is a collection of nodes with various fields
It contains data field and Address field or Linkfield
Info field Link Field/
Address Field
Pointer to the
first node
ARRAYS VS LINKEDLISTS
Arrays Linked list
Fixed size: Resizing is expensive Dynamic size
Insertions and Deletions are inefficient:
Elements are usually shifted
Insertions and Deletions are efficient: No
shifting
Random access i.e., efficient indexing No random access
 Not suitable for operations requiring
accessing elements by index such as sorting
No memory waste if the array is full or almost
full; otherwise may result in much memory
waste.
Since memory is allocated dynamically(acc. to
our need) there is no waste of memory.
Sequential access is faster [Reason: Elements in
contiguous memory locations]
Sequential access is slow [Reason: Elements not
in contiguous memory locations]
TYPES OF LINKED LISTS
1. Single linked list
2. Double linked list
3. Circular linked list
4. Circular double linked list
SINGLE LINKED LIST :-
• A single linked list is one in which all
nodes are linked together in some
sequential manner.
• CIRCULAR LINKED LIST :-
• A circular linked list is one which has
no beginning and no ending. The null
pointer in the last node of a linked list
is replaced with the address of its first
node such a list is called circular linked
list.
Graphical Representation
10
1000 2000
2000
1000 15 NULL
20
4000
Singly Linked List
First
Graphical Representation
10
1000 2000
2000
1000 15 20 4000
4000
Circular Singly Linked List
Last node contains the address of the first node
First
SINGLE LINKED LIST :
Start
CIRCULAR LINKED LIST:-
100 200
35 N
60 200
45 100
60 200 35 400
45 100
400
500
Inserting a new node :
Before inserting:
100 200
400
After inserting:
400 100
200
20 N
35 200
14 100
20 N
35 200
14 100
75 400
Delete a node from the list:
before deletion:
300 500
200 400
after deletion :
200 300 500
46 500
48 300
35 400 30 N
30 N
46 500
35 300
 In circular linked list we have three
functions. They are
• addcirq( )
• delcirq( )
• cirq_display( )
function accepts three
addcirq( ) :-
This
parameters.
 First parameter receives the address
of the first node.
 The second parameter receives the
address of the pointer to the last node.
Delcirq( ) :-
This function receives two parameters.
 The first parameter is the pointer to the
front node.
 The second is the pointer to the rear.
front rear
10 5
16
17
.DOUBLE LINKED LIST :-
has some
A single linked list
disadvantages
• That it can traverse it in one direction.
searching
travelling
• Many applications require
backword and forword
sections of a list
• A two way list is a linear collection of
data elements called nodes.
• When each node is divided into three
parts. They are two link parts and one
data part.
node
prev data next
Doubly Linked list
Contains the address of previous node and
next node
NULL
2000 3000
1000
10 2000 2000 20 NU LL
1000 15 3000
First
Inserting a new node :
Before insertion:-
100 400
200
After insertion:-
100 40 N
200 20 400
N 11 100
100 40 N
400 25 100
N 11 100 200 20 400
Delete a node from the list:
Before deletion:-
600 200 400
After deletion:-
200 400
200 4 N
600 11 400
N 5 200
N 11 400 200 4 N
Circular Doubly Linked list
Contains the address of first node and last
node
3000
2000 3000
1000
10 2000 2000 00
20 10
1000 15 3000
First
REVERSING THE LINKS :
Reversing means the last node
becomes the first node and the first
becomes the last.
N
5 23 3 17
17
3
23
5 N
23
3
17
5
MERGING OF LINKED LIST :
• suppose we have two linked lists.
• That are pointed to two independent
pointers. We have to merge the two
links into a third list.
• By using this merge ( ) to ensure that
those elements which are common to
both the lists occur only once in the
third list.
9 12 14 N
12 17 24 N
9 12 14 17 24
N
SORTING OF A LINKED LIST :
• Sorting means to arrange the elements
either in ascending or descending
order.
• To sort the elements of a linked list we
use any of the standard sorting
algorithms for carrying out the sorting.
• While performing the sorting, when it is
time to exchange two elements, we
can adopt any of the following two
strategies.
1)Exchange the data part of the two
nodes, keeping the links intact.
8 N
4
3
2
3 N
4
8
2
2) Keep the data in the nodes intact.
the
order
links such that
of the nodes
Simply readjust
effectively the
changes
200 400 0 600
11 N
4 40
0
8 60
0
2 50
0
11 N
4 600
8 500
2 400
RECURSIVE OPERATIONS ON LINKED
LIST :
 A function called by itself known as
recursion.
 If a statement within the body of a
function calls the same function.
 Some of the operations that are carried
out on linked list can be easily
implemented using recursion.
 For example finding out the number of
nodes present in a linked list, comparing
two lists, copying one linked list into
another, adding a new node at the end
of the linked list, etc.,
OPERATIONS ON LINKED LISTS
The basic operations on linked lists are
1. Creation
2. Insertion
3. Deletion
4. Traversing
5. Searching
6. Concatenation
7. Display
• The creation operation is used to
create a linked list.
• Insertion operation is used to insert a
new node in the linked list at the
specified position. A new node may be
inserted at the beginning of a linked list ,
at the end of the linked list , at the
specified position in a linked list. If the
list itself is empty , then the new node is
inserted as a first node.
• Deletion operation is used to delete on
item from the linked list. It may be deleted
from the beginning of a linked list ,
specified position in the list.
• Traversing operation is a process of
going through all the nodes of a linked list
from one end to the another end. If we
start traversing from the very first node
towards the last node , It is called
forward traversing.
• If the traversal start from the last node
towards the first node , it is called back
word traversing.
• Searching operation is a process of
accessing the desired node in the list.
We start searching node –by-node and
compare the data of the node with the
key.
• Concatenation operation is the process
of appending the second list to the end
of the first list. When we concatenate
two lists , the resultant list becomes
larger in size.
• The display operation is used to print
each and every node’s information.
BASICOPERATIONS ON A LIST
• Creating a List
• Inserting an element in a list
• Deleting an element from a list
• Searching a list
• Reversing a list
INSERTION AT THE BEGINNING
There are two steps to be followed:-
a) Make the next pointer of the node point
towards the first node of the list
b) Make the start pointer point towards this new
node
 If the list is empty simply make the start pointer
point towards the new node;
INSERTING THE NODE IN A SLL
There are 3 cases here:-
 Insertion at the beginning
 Insertion at the end
 Insertion after a particular node
INSERTING AT THE END
Here we simply need to make the next
pointer
of the last node point to the new node
INSERTING AFTER AN ELEMENT
Here we again need to do 2 steps :-
 Make the next pointer of the node to be inserted
point to the next node of the node after which you
want to insert the node
 Make the next pointer of the node after which the
node is to be inserted, point to the node to be
inserted
DELETING A NODE INSLL
Here also we have three cases:-
 Deleting the first node
 Deleting the last node
 Deleting the intermediate node
DELETING THE FIRST NODE
three
two
one
Here we apply 2 steps:-
 Making the start pointer point towards the 2nd
node
 Deleting the first node using delete keyword
s t a r t
DELETING THE LAST NODE
node1 node2 node3
Here we apply 2 steps:-
 Making the second last node’s next pointer point
to NULL
 Deleting the last node via delete keyword
start
DELETING A PARTICULARNODE
Here we make the next pointer of the node
previous to the node being deleted ,point to
the successor node of the node to be deleted
and then delete the node using delete
keyword
node1 node2 node3
To be deleted
SEARCHING
Searching involves finding the required element in the
list
We can use various techniques of searching like linear
search or binary search where binary search is more
efficient in case of Arrays
But in case of linked list since random access is not
available it would become complex to do binary search
in it
We can perform simple linear search traversal
In linear search each node is traversed till the data
in the node matches with the required value
REVERSING A LINKEDLIST
• We can reverse a linked list by reversing the
direction of the links between 2 nodes
Operation ID-Array Complexity Singly-linked list Complexity
Insert at beginning O(n) O(1)
Insert at end O(1) O(1) if the list has tail reference
O(n) if the list has no tail reference
Insert at middle O(n) O(n)
Delete at beginning O(n) O(1)
Delete at end O(1) O(n)
Delete at middle O(n):
O(1) access followed by O(n)
shift
O(n):
O(n) search, followed by O(1) delete
Search O(n) linear search
O(log n) Binary search
O(n)
Indexing: What is
the element at a
given position k?
O(1) O(n)
COMPLEXITY OF VARIOUS
OPERATIONS IN ARRAYS AND SLL
DOUBLY LINKED LIST
1. Doubly linked list is a linked data structure that consists of a set of
sequentially linked records called nodes.
2 . Each node contains three fields ::
-: one is data part which contain data only.
-:two other field is links part that are point
or references to the previous or to the next
node in the sequence of nodes.
3. The beginning and ending nodes' previous and next
links, respectively, point to some kind of terminator,
typically a sentinel node or null to facilitate traversal
of the list.
NODE
A B
C
A doubly linked list contain three fields: an integer
value, the link to the next node, and the link to the
previous data next
NULL 11 786
786
200 400
200 656 400 786 777 NULL
DLL’S COMPARED TOSLL’S
Advantages:
Can be traversed in
either direction (may be
essential for some
programs)
Some operations, such
as deletion and inserting
before a node, become
easier
Disadvantages:
Requires more space
List manipulations are
slower (because more
links must be changed)
Greater chance of
having bugs (because
more links must be
manipulated)
STRUCTURE OF DLL
.Data .next
previous.
inf
INSERTING ATBEGINNING
INSERTING AT THE END
Making next and previous pointer of the node to be
inserted point accordingly
Adjusting the next and previous pointers of the nodes b/w
which the new node accordingly
INSERTING AFTER A NODE
DELETING A NODE
• Node deletion from a DLL involves changing two links
• In this example,we will delete node b
myDLL
a b c
• We don’t have to do anything about the links in node
b
• Garbage collection will take care of deleted nodes
• Deletion of the first node or the last node is a special
case
ADVANTAGES OF LINKEDLISTS
•We can dynamically allocate memory
space as needed
•We can release the unused space in the
situation where the allocated space
seems to be more.
•Operation related to data elements like
insertions or deletion are more
simplified.
•Operation like insertion or deletion are
less time consuming.
•Linked lists provide flexibility in allowing
the items to be arranged efficiently.

More Related Content

What's hot

Arrays
ArraysArrays
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
DivyeshKumar Jagatiya
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
Huba Akhtar
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
Afaq Mansoor Khan
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
DurgaDeviCbit
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
Linked list
Linked listLinked list
Linked list
Md. Afif Al Mamun
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
Venugopalavarma Raja
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
Arun Sial
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
BHARATH KUMAR
 
Ppt of dbms e r features
Ppt of dbms e r featuresPpt of dbms e r features
Ppt of dbms e r features
Nirali Akabari
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
Reazul Islam
 
Normal forms
Normal formsNormal forms
Normal forms
Samuel Igbanogu
 
16 dynamic-memory-allocation
16 dynamic-memory-allocation16 dynamic-memory-allocation
16 dynamic-memory-allocation
Rohit Shrivastava
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Namespaces
NamespacesNamespaces
Namespaces
Sangeetha S
 
Linked list
Linked listLinked list
Linked list
MahammadAdil
 

What's hot (20)

Arrays
ArraysArrays
Arrays
 
Expression trees
Expression treesExpression trees
Expression trees
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 
Linked list
Linked listLinked list
Linked list
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
 
SQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTIONSQL BUILT-IN FUNCTION
SQL BUILT-IN FUNCTION
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
 
Ppt of dbms e r features
Ppt of dbms e r featuresPpt of dbms e r features
Ppt of dbms e r features
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Normal forms
Normal formsNormal forms
Normal forms
 
16 dynamic-memory-allocation
16 dynamic-memory-allocation16 dynamic-memory-allocation
16 dynamic-memory-allocation
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Namespaces
NamespacesNamespaces
Namespaces
 
Linked list
Linked listLinked list
Linked list
 

Similar to Linked list (1).pptx

linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
KamranAli649587
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power p
MeghaKulkarni27
 
Linkedlists
LinkedlistsLinkedlists
Linkedlists
Rajendran
 
Linked lists
Linked listsLinked lists
Linked lists
SARITHA REDDY
 
linked list using c
linked list using clinked list using c
linked list using c
Venkat Reddy
 
Linkedlist
LinkedlistLinkedlist
1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
ssuserd2f031
 
Linked list
Linked listLinked list
Linked list
Muhammad Qasim
 
Data Structures and Algorithms - Lec 05.pptx
Data Structures and Algorithms - Lec 05.pptxData Structures and Algorithms - Lec 05.pptx
Data Structures and Algorithms - Lec 05.pptx
RameshaFernando2
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
NathanielAdika
 
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptxDATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
SKUP1
 
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptxDATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
LECO9
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
ssuser7922b8
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
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
Estiak Khan
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
LavanyaJ28
 
Different types of Linked list.
Different types of Linked list.Different types of Linked list.
Different types of Linked list.
JAYANTAOJHA
 
csc211_lecture_21.pptx
csc211_lecture_21.pptxcsc211_lecture_21.pptx
csc211_lecture_21.pptx
ASADAHMAD811380
 
Linked List
Linked ListLinked List
Linked List
BHARATH KUMAR
 

Similar to Linked list (1).pptx (20)

linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power p
 
Linkedlists
LinkedlistsLinkedlists
Linkedlists
 
Linked lists
Linked listsLinked lists
Linked lists
 
linked list using c
linked list using clinked list using c
linked list using c
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
 
Linked list
Linked listLinked list
Linked list
 
Data Structures and Algorithms - Lec 05.pptx
Data Structures and Algorithms - Lec 05.pptxData Structures and Algorithms - Lec 05.pptx
Data Structures and Algorithms - Lec 05.pptx
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
 
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptxDATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
 
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptxDATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
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
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Different types of Linked list.
Different types of Linked list.Different types of Linked list.
Different types of Linked list.
 
csc211_lecture_21.pptx
csc211_lecture_21.pptxcsc211_lecture_21.pptx
csc211_lecture_21.pptx
 
Linked List
Linked ListLinked List
Linked List
 

Recently uploaded

Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 

Recently uploaded (20)

Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 

Linked list (1).pptx

  • 1. DATASTRUCTURE DATRUCTURE IS THE WAY OF ORGANIZING ALL DATA ITEMS IN ORDER THAT NOT ONLY ELEMENTS TO BE STORED BUT ALSO THE RELATION BETWEEN THEELEMENTS
  • 2. INTRODUCTION  Data structure:-A data structure is a logical representation of data and operation that can be performed on the data. 1)linear data structure 2)Non linear data structure  Linear data structure is an order of data elements. They are arrays, stacks, queues, and linked lists.
  • 3. Linked list :- linked list is a linear data structure. It contains nodes. Each node contains two parts, i.e. DATApart and LINK part.  The data contains elements and  Link contains address of another node.
  • 4. LIMITATIONS OF ARRAYS  Arrays are simple to understand and elements of an array are easily accessible  But arrays have some limitations.  Arrays have a fixed dimension.  Once the size of an array is decided it can not be increased or decreased during education.
  • 5.  Array elements are always stored in contiguous memory locations.  Operations like insertion or deletion of the array are pretty tedious.  T o over come this limitations we use linked list.
  • 6. LINKED LISTS  Linked list is a collection of elements called nodes.  Each node contains two parts. they are data part and link part. Node data link
  • 7. 100 200 400 • The above figure shows the example of marks obtained by different students can be stored in a linked list • Here N-stands for NULL. • Null indicates the end of the node. 14 100 30 400 42 N
  • 8. WHAT ARE LINKEDLISTS A linked list is a linear data structure. Nodes make up linked lists. Nodes are structures made up of data and a pointer to another node. Usually the pointer is called next.
  • 9. What is Linked List? A linked list is a collection of nodes with various fields It contains data field and Address field or Linkfield Info field Link Field/ Address Field Pointer to the first node
  • 10. ARRAYS VS LINKEDLISTS Arrays Linked list Fixed size: Resizing is expensive Dynamic size Insertions and Deletions are inefficient: Elements are usually shifted Insertions and Deletions are efficient: No shifting Random access i.e., efficient indexing No random access  Not suitable for operations requiring accessing elements by index such as sorting No memory waste if the array is full or almost full; otherwise may result in much memory waste. Since memory is allocated dynamically(acc. to our need) there is no waste of memory. Sequential access is faster [Reason: Elements in contiguous memory locations] Sequential access is slow [Reason: Elements not in contiguous memory locations]
  • 11. TYPES OF LINKED LISTS 1. Single linked list 2. Double linked list 3. Circular linked list 4. Circular double linked list
  • 12. SINGLE LINKED LIST :- • A single linked list is one in which all nodes are linked together in some sequential manner. • CIRCULAR LINKED LIST :- • A circular linked list is one which has no beginning and no ending. The null pointer in the last node of a linked list is replaced with the address of its first node such a list is called circular linked list.
  • 13. Graphical Representation 10 1000 2000 2000 1000 15 NULL 20 4000 Singly Linked List First
  • 14. Graphical Representation 10 1000 2000 2000 1000 15 20 4000 4000 Circular Singly Linked List Last node contains the address of the first node First
  • 15. SINGLE LINKED LIST : Start CIRCULAR LINKED LIST:- 100 200 35 N 60 200 45 100 60 200 35 400 45 100 400 500
  • 16. Inserting a new node : Before inserting: 100 200 400 After inserting: 400 100 200 20 N 35 200 14 100 20 N 35 200 14 100 75 400
  • 17. Delete a node from the list: before deletion: 300 500 200 400 after deletion : 200 300 500 46 500 48 300 35 400 30 N 30 N 46 500 35 300
  • 18.  In circular linked list we have three functions. They are • addcirq( ) • delcirq( ) • cirq_display( )
  • 19. function accepts three addcirq( ) :- This parameters.  First parameter receives the address of the first node.  The second parameter receives the address of the pointer to the last node.
  • 20. Delcirq( ) :- This function receives two parameters.  The first parameter is the pointer to the front node.  The second is the pointer to the rear. front rear 10 5 16 17
  • 21. .DOUBLE LINKED LIST :- has some A single linked list disadvantages • That it can traverse it in one direction. searching travelling • Many applications require backword and forword sections of a list
  • 22. • A two way list is a linear collection of data elements called nodes. • When each node is divided into three parts. They are two link parts and one data part. node prev data next
  • 23. Doubly Linked list Contains the address of previous node and next node NULL 2000 3000 1000 10 2000 2000 20 NU LL 1000 15 3000 First
  • 24. Inserting a new node : Before insertion:- 100 400 200 After insertion:- 100 40 N 200 20 400 N 11 100 100 40 N 400 25 100 N 11 100 200 20 400
  • 25. Delete a node from the list: Before deletion:- 600 200 400 After deletion:- 200 400 200 4 N 600 11 400 N 5 200 N 11 400 200 4 N
  • 26. Circular Doubly Linked list Contains the address of first node and last node 3000 2000 3000 1000 10 2000 2000 00 20 10 1000 15 3000 First
  • 27. REVERSING THE LINKS : Reversing means the last node becomes the first node and the first becomes the last. N 5 23 3 17 17 3 23 5 N 23 3 17 5
  • 28. MERGING OF LINKED LIST : • suppose we have two linked lists. • That are pointed to two independent pointers. We have to merge the two links into a third list. • By using this merge ( ) to ensure that those elements which are common to both the lists occur only once in the third list.
  • 29. 9 12 14 N 12 17 24 N 9 12 14 17 24 N
  • 30. SORTING OF A LINKED LIST : • Sorting means to arrange the elements either in ascending or descending order. • To sort the elements of a linked list we use any of the standard sorting algorithms for carrying out the sorting. • While performing the sorting, when it is time to exchange two elements, we can adopt any of the following two strategies.
  • 31. 1)Exchange the data part of the two nodes, keeping the links intact. 8 N 4 3 2 3 N 4 8 2
  • 32. 2) Keep the data in the nodes intact. the order links such that of the nodes Simply readjust effectively the changes 200 400 0 600 11 N 4 40 0 8 60 0 2 50 0 11 N 4 600 8 500 2 400
  • 33. RECURSIVE OPERATIONS ON LINKED LIST :  A function called by itself known as recursion.  If a statement within the body of a function calls the same function.  Some of the operations that are carried out on linked list can be easily implemented using recursion.
  • 34.  For example finding out the number of nodes present in a linked list, comparing two lists, copying one linked list into another, adding a new node at the end of the linked list, etc.,
  • 35. OPERATIONS ON LINKED LISTS The basic operations on linked lists are 1. Creation 2. Insertion 3. Deletion 4. Traversing 5. Searching 6. Concatenation 7. Display
  • 36. • The creation operation is used to create a linked list. • Insertion operation is used to insert a new node in the linked list at the specified position. A new node may be inserted at the beginning of a linked list , at the end of the linked list , at the specified position in a linked list. If the list itself is empty , then the new node is inserted as a first node.
  • 37. • Deletion operation is used to delete on item from the linked list. It may be deleted from the beginning of a linked list , specified position in the list. • Traversing operation is a process of going through all the nodes of a linked list from one end to the another end. If we start traversing from the very first node towards the last node , It is called forward traversing.
  • 38. • If the traversal start from the last node towards the first node , it is called back word traversing. • Searching operation is a process of accessing the desired node in the list. We start searching node –by-node and compare the data of the node with the key.
  • 39. • Concatenation operation is the process of appending the second list to the end of the first list. When we concatenate two lists , the resultant list becomes larger in size. • The display operation is used to print each and every node’s information.
  • 40. BASICOPERATIONS ON A LIST • Creating a List • Inserting an element in a list • Deleting an element from a list • Searching a list • Reversing a list
  • 41. INSERTION AT THE BEGINNING There are two steps to be followed:- a) Make the next pointer of the node point towards the first node of the list b) Make the start pointer point towards this new node  If the list is empty simply make the start pointer point towards the new node;
  • 42. INSERTING THE NODE IN A SLL There are 3 cases here:-  Insertion at the beginning  Insertion at the end  Insertion after a particular node
  • 43.
  • 44. INSERTING AT THE END Here we simply need to make the next pointer of the last node point to the new node
  • 45. INSERTING AFTER AN ELEMENT Here we again need to do 2 steps :-  Make the next pointer of the node to be inserted point to the next node of the node after which you want to insert the node  Make the next pointer of the node after which the node is to be inserted, point to the node to be inserted
  • 46.
  • 47. DELETING A NODE INSLL Here also we have three cases:-  Deleting the first node  Deleting the last node  Deleting the intermediate node
  • 48. DELETING THE FIRST NODE three two one Here we apply 2 steps:-  Making the start pointer point towards the 2nd node  Deleting the first node using delete keyword s t a r t
  • 49. DELETING THE LAST NODE node1 node2 node3 Here we apply 2 steps:-  Making the second last node’s next pointer point to NULL  Deleting the last node via delete keyword start
  • 50. DELETING A PARTICULARNODE Here we make the next pointer of the node previous to the node being deleted ,point to the successor node of the node to be deleted and then delete the node using delete keyword node1 node2 node3 To be deleted
  • 51. SEARCHING Searching involves finding the required element in the list We can use various techniques of searching like linear search or binary search where binary search is more efficient in case of Arrays But in case of linked list since random access is not available it would become complex to do binary search in it We can perform simple linear search traversal In linear search each node is traversed till the data in the node matches with the required value
  • 52. REVERSING A LINKEDLIST • We can reverse a linked list by reversing the direction of the links between 2 nodes
  • 53. Operation ID-Array Complexity Singly-linked list Complexity Insert at beginning O(n) O(1) Insert at end O(1) O(1) if the list has tail reference O(n) if the list has no tail reference Insert at middle O(n) O(n) Delete at beginning O(n) O(1) Delete at end O(1) O(n) Delete at middle O(n): O(1) access followed by O(n) shift O(n): O(n) search, followed by O(1) delete Search O(n) linear search O(log n) Binary search O(n) Indexing: What is the element at a given position k? O(1) O(n) COMPLEXITY OF VARIOUS OPERATIONS IN ARRAYS AND SLL
  • 54. DOUBLY LINKED LIST 1. Doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. 2 . Each node contains three fields :: -: one is data part which contain data only. -:two other field is links part that are point or references to the previous or to the next node in the sequence of nodes. 3. The beginning and ending nodes' previous and next links, respectively, point to some kind of terminator, typically a sentinel node or null to facilitate traversal of the list.
  • 55. NODE A B C A doubly linked list contain three fields: an integer value, the link to the next node, and the link to the previous data next NULL 11 786 786 200 400 200 656 400 786 777 NULL
  • 56. DLL’S COMPARED TOSLL’S Advantages: Can be traversed in either direction (may be essential for some programs) Some operations, such as deletion and inserting before a node, become easier Disadvantages: Requires more space List manipulations are slower (because more links must be changed) Greater chance of having bugs (because more links must be manipulated)
  • 57. STRUCTURE OF DLL .Data .next previous. inf
  • 60. Making next and previous pointer of the node to be inserted point accordingly Adjusting the next and previous pointers of the nodes b/w which the new node accordingly INSERTING AFTER A NODE
  • 61. DELETING A NODE • Node deletion from a DLL involves changing two links • In this example,we will delete node b myDLL a b c • We don’t have to do anything about the links in node b • Garbage collection will take care of deleted nodes • Deletion of the first node or the last node is a special case
  • 62. ADVANTAGES OF LINKEDLISTS •We can dynamically allocate memory space as needed •We can release the unused space in the situation where the allocated space seems to be more. •Operation related to data elements like insertions or deletion are more simplified.
  • 63. •Operation like insertion or deletion are less time consuming. •Linked lists provide flexibility in allowing the items to be arranged efficiently.