Linked list module full chapter sujruejejej

samareddy6668 10 views 24 slides Sep 22, 2024
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

Linked list module full chapter sujruejejej


Slide Content

Chandigarh Group of Colleges, Landran
MODULE 3
LINKED LIST

Chandigarh Group of Colleges, Landran
LINKED LIST Definition:
•Alinked listis a linear data structure where each element is a
separate object.
•Linked listelements are not stored at contiguous location; the
elements arelinkedusing pointers.
•LINKED LIST is a collection of data elements called nodes
where the linear order is given by means of pointer.
•Each node of alistis made up of two items -the data and a
reference to the next node.
•The last node has a reference to null.

Chandigarh Group of Colleges, Landran
Representation of a node:

Chandigarh Group of Colleges, Landran

Chandigarh Group of Colleges, Landran
Representation of Linear Linked List:

Chandigarh Group of Colleges, Landran
Example of linked list :

Chandigarh Group of Colleges, Landran
Example of Linked List:

Chandigarh Group of Colleges, Landran
Example of linked list :

Chandigarh Group of Colleges, Landran
Example of LINKED List:

Chandigarh Group of Colleges, Landran
Representation in Memory:

Chandigarh Group of Colleges, Landran
PRACTICE QUESTION
INFO LINK
1
2
3
4
5
A
A
P
K
L
5
4
1
X
2
START
3

Chandigarh Group of Colleges, Landran
Types of Linked list:
•Linear or Single linked list
•Circular Linked List
•Two way or Doubly Linked list

Chandigarh Group of Colleges, Landran
Singly or Linear linked list
VS
Circular Linked List:

Chandigarh Group of Colleges, Landran
Single or Linear linked list
VS
Double Linked List:

Chandigarh Group of Colleges, Landran
Operations on Linear Linked List:
1. Traversing:
•ALGORITHM:-
TRAVERSE( LIST, START , PTR, INFO , LINK)
LIST is linear linked list stored in memory, START Pointer points to
first node, PTR is pointer that points to the node currently being
processed, INFO contains data elements and LINK that stores the
address of next node.
1.Set PTR:=START. [Initializes pointer PTR]
2.Repeat steps 3 and 4 while PTR!=NULL.
3.Apply PROCESS to INFO[PTR].
4.Set PTR:=LINK[PTR].[PTR now points the next node].
[End of step 2 loop]
5.Exit.

Chandigarh Group of Colleges, Landran
TRAVERSING A LINKED LIST EXAMPLE:

Chandigarh Group of Colleges, Landran
TRAVERSING A LINKED LIST EXAMPLE:

Chandigarh Group of Colleges, Landran
TRAVERSING SOLVED EXAMPLE 1:

Chandigarh Group of Colleges, Landran
TRAVERSING SOLVED EXAMPLE 1 contd:

Chandigarh Group of Colleges, Landran
TRAVERSING SOLVED EXAMPLE 2 :

Chandigarh Group of Colleges, Landran
TRAVERSING SOLVED EXAMPLE 2 contd:

Chandigarh Group of Colleges, Landran
2
L
H
O
E
R
L
D
O
L
W
8
4
5
6
9
1
X
10
7
3
TRAVERSING SOLVED EXAMPLE 3 :
START
INFO LINK
1
2
3
4
6
7
8
9
10
5

Chandigarh Group of Colleges, Landran
TRAVERSING SOLVED EXAMPLE 3 contd:

Chandigarh Group of Colleges, Landran
TRAVERSING SOLVED EXAMPLE 3 contd:
Tags