SlideShare a Scribd company logo
Lists
By
Muskan. S
(Embedded System and VLSI)
2
Lists
⚫ Alists (Linear linked list) can be defined as a
collection of variable number of data items called nodes.
⚫ Lists are the most commonly used non- primitive data structures.
⚫ Each nodes is divided into two parts:
◦ The first part contains the information of the element.
◦ o The second part contains the memory address of the next node in the
list.Also called Link part.
3
Lists
⚫Types of linked lists:
◦ Single linked list
◦ Doubly linked list
◦ Single circular linked list
◦ Doubly circular linked list
4
Single linked list
Asingly linked list contains two fields in each node - an
information field and the linked field.
•The information field contains the data of that node.
•The link field contains the memory address of the next node. There is
only one link field in each node, the linked list is called singly linked list.
5
Single circular linked list
The link field of the last node contains the memory address of the first
node, such a linked list is called circular linked list.
· In a circular linked list every node is accessible from a given node.
6
Doubly linked list
It is a linked list in which each node is points both to the next node and also
to the previous node.
⚫ In doubly linked list each node contains three parts:
◦ FORW : It is a pointer field that contains the address of the next node
◦ BACK: It is a pointer field that contains the address of the previous node.
◦ INFO: It contains the actual data.
⚫ In the first node, if BACK contains NULL, it indicated that it is the first
node in the list.
⚫ The node in which FORW contains, NULL indicates that the node is the last node.
7
Doubly circular linked list
8
Operation on Linked List
⚫The operation that are performed on
linked lists are:
◦ Creating a linked list
◦ Traversing a linked list
◦ Inserting an item into a linked list.
◦ Deleting an item from the linked list.
◦ Searching an item in the linked list
◦ Merging two or more linked lists.
9
Creating a linked list
⚫ The nodes of a linked list can be created by the following
structure declaration.
struct Node
{
int info;
struct Node *link;
}*node1, node2;
⚫ Here info is the information field and link is the link field.
⚫ The link field contains a pointer variable that refers the same node
structure. Such a reference is called as Self addressing pointer.
10
Operator new and delete
⚫Operators new allocate memory space.
◦ Operators new [ ] allocatesmemory space for array.
⚫Operators delete deallocate memory space.
◦ Operators delete[ ] deallocatememory space for array.
11
Traversing a linked list:
⚫ Traversing is the process of accessing each node of the linked list
exactly once to perform some operation.
⚫ ALGORITHM: TRAVERS (START, P) START contains
the address of the first node.Another pointer p is temporarily used to
visit all the nodes from the beginning to the end of the linked list.
Step 1: P = START
Step 2: while P != NULL
Step 3:
Step 4:
PROCESS data (P)
P = link(P)
[Fetch the data]
[Advance P to next node]
Step 5: End of while
Step 6: Return
12
Inserting a node into the linked list
⚫Inserting a node at the beginning of the linked
list
⚫Inserting a node at the given position.
⚫Inserting a node at the end of the linked list.
13
Inserting node at Front
Inserting a node at the beginning of the linked list
1. Create a node.
2. Fill data into the data field of the new node.
3. Mark its pointer field as NULL
4. Attach this newly created node to START
5. Make the new node as the START node.
14
Inserting node at Front
⚫ALGORITHM: INS_BEG (START, P)
START contains the address of the first
node.
Step 1: P new Node;
num;
START
P
Step 2: data(P)
Step 3: link(P)
Step 4: START
Step 5: Return
15
Inserting node at Last
16
Inserting node at Last
⚫ ALGORITHM: INS_END (START, P) START contains
the address of the first node.
Step 1: START
Step 2: P START [identify the last node]
while P!= null
P next (P)
End while
Step 3: N new Node;
Step 4: data(N) item;
Step 5: link(N) null
Step 6: link(P) N
Step 7: Return Prof. K. Adisesha 75
17
Inserting node at a given Position
count+1
next (P)
Count 0
Step 3: while P!= null
count
P
End while
Step 4: if (POS=1)
Call function INS_BEG( )
else if (POS=Count +1)
Call function INS_END( )
For(i=1; i<=pos; i++)
P next(P);
end for
new node
item;
link(P)
N
[create] N
data(N)
link(N)
link(P)
else
PRINT “Invalid position”
Step 5: Return
ALGORITHM: INS_POS (START, P) START contains the
address of the first node.
Step 1: START else if (POS<=Count)
Step 2: P START [Initialize node] P Start
18
Deleting an node
⚫Deleting an item from the linked list:
o Deletion of the first node
o Deletion of the last node
o Deletion of the node at the give position
19
Deleting node from end
ALGORITHM: DEL_END (P1, P2, START) This used two
pointers P1 and P2. Pointer P2 is used to traverse the linked list
and pointer P1 keeps the location of the previous node of P2.
Step 1: START
Step 2: P2 START;
Step 3: while ( link(P2) ! = NULL)
P1 P2
P2 link(P2)
While end
Step 4: PRINT data(p2)
NULL
Step 5: link(P1)
Free(P2)
Step 6: STOP
20
Deleting node from end
THANK YOU

More Related Content

Similar to data structures lists operation of lists (20)

PPTX
Linked list and its operations - Traversal
kasthurimukila
 
PDF
Singly linked list
Amar Jukuntla
 
PPTX
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
PPTX
Linked List in Data Structure
Meghaj Mallick
 
PPTX
linked list
Ayesha Sajjad
 
PPTX
Linked lists a
Khuram Shahzad
 
PDF
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
 
PPTX
Engineering.CSE.DataStructure.Linkedlist.notes
limev72215
 
PDF
DS Module 03.pdf
SonaPathak5
 
PPTX
Data structure week y 4
karmuhtam
 
PPTX
DSL Unit 4 (Linked list) (PPT)SE3rd sem sppu.pptx
vaibhavkore8
 
PPT
ANOITO2341988888888888888888888885555.ppt
robertobula2
 
PPTX
Unit 5 linked list
Dabbal Singh Mahara
 
PPTX
1.3 Linked List.pptx
ssuserd2f031
 
PPT
Operations on linked list
Sumathi Kv
 
DOCX
Link list assi
PATILPANKAJ106130
 
PPTX
Deletion from single way linked list and search
Estiak Khan
 
PDF
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Balwant Gorad
 
PPTX
Module 3 Dara structure notes
Dreamers6
 
PDF
ds-lecture-4-171012041008 (1).pdf
KamranAli649587
 
Linked list and its operations - Traversal
kasthurimukila
 
Singly linked list
Amar Jukuntla
 
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
Linked List in Data Structure
Meghaj Mallick
 
linked list
Ayesha Sajjad
 
Linked lists a
Khuram Shahzad
 
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
 
Engineering.CSE.DataStructure.Linkedlist.notes
limev72215
 
DS Module 03.pdf
SonaPathak5
 
Data structure week y 4
karmuhtam
 
DSL Unit 4 (Linked list) (PPT)SE3rd sem sppu.pptx
vaibhavkore8
 
ANOITO2341988888888888888888888885555.ppt
robertobula2
 
Unit 5 linked list
Dabbal Singh Mahara
 
1.3 Linked List.pptx
ssuserd2f031
 
Operations on linked list
Sumathi Kv
 
Link list assi
PATILPANKAJ106130
 
Deletion from single way linked list and search
Estiak Khan
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Balwant Gorad
 
Module 3 Dara structure notes
Dreamers6
 
ds-lecture-4-171012041008 (1).pdf
KamranAli649587
 

More from muskans14 (9)

PPTX
LOGIC LEVEL PPT.pptx on low power vlsi design
muskans14
 
PPTX
ECE6003-Module_1.pptx electronics and communication
muskans14
 
PPTX
Untitled.pptx laboratory diagnostic of cancer
muskans14
 
PPTX
PATHOLOGY PPT.pptx thrombosis and cancer
muskans14
 
PPT
ppt.ppt on didgital logic design by muskan.s
muskans14
 
PDF
wepik-revolutionizing-tomorrow-cutting-edge-breakthroughs-in-vlsi-technology-...
muskans14
 
PPTX
Queue data structures and operation on data structures
muskans14
 
PPTX
wepik-vlsi-vroom-zooming-into-the-coolest-chip-innovations-20240218112906VNy9...
muskans14
 
PPTX
VLSI TECHNOLOGY AND ITS LATEST INNOVATIONS
muskans14
 
LOGIC LEVEL PPT.pptx on low power vlsi design
muskans14
 
ECE6003-Module_1.pptx electronics and communication
muskans14
 
Untitled.pptx laboratory diagnostic of cancer
muskans14
 
PATHOLOGY PPT.pptx thrombosis and cancer
muskans14
 
ppt.ppt on didgital logic design by muskan.s
muskans14
 
wepik-revolutionizing-tomorrow-cutting-edge-breakthroughs-in-vlsi-technology-...
muskans14
 
Queue data structures and operation on data structures
muskans14
 
wepik-vlsi-vroom-zooming-into-the-coolest-chip-innovations-20240218112906VNy9...
muskans14
 
VLSI TECHNOLOGY AND ITS LATEST INNOVATIONS
muskans14
 
Ad

Recently uploaded (20)

PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Design Thinking basics for Engineers.pdf
CMR University
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Ad

data structures lists operation of lists

  • 2. 2 Lists ⚫ Alists (Linear linked list) can be defined as a collection of variable number of data items called nodes. ⚫ Lists are the most commonly used non- primitive data structures. ⚫ Each nodes is divided into two parts: ◦ The first part contains the information of the element. ◦ o The second part contains the memory address of the next node in the list.Also called Link part.
  • 3. 3 Lists ⚫Types of linked lists: ◦ Single linked list ◦ Doubly linked list ◦ Single circular linked list ◦ Doubly circular linked list
  • 4. 4 Single linked list Asingly linked list contains two fields in each node - an information field and the linked field. •The information field contains the data of that node. •The link field contains the memory address of the next node. There is only one link field in each node, the linked list is called singly linked list.
  • 5. 5 Single circular linked list The link field of the last node contains the memory address of the first node, such a linked list is called circular linked list. · In a circular linked list every node is accessible from a given node.
  • 6. 6 Doubly linked list It is a linked list in which each node is points both to the next node and also to the previous node. ⚫ In doubly linked list each node contains three parts: ◦ FORW : It is a pointer field that contains the address of the next node ◦ BACK: It is a pointer field that contains the address of the previous node. ◦ INFO: It contains the actual data. ⚫ In the first node, if BACK contains NULL, it indicated that it is the first node in the list. ⚫ The node in which FORW contains, NULL indicates that the node is the last node.
  • 8. 8 Operation on Linked List ⚫The operation that are performed on linked lists are: ◦ Creating a linked list ◦ Traversing a linked list ◦ Inserting an item into a linked list. ◦ Deleting an item from the linked list. ◦ Searching an item in the linked list ◦ Merging two or more linked lists.
  • 9. 9 Creating a linked list ⚫ The nodes of a linked list can be created by the following structure declaration. struct Node { int info; struct Node *link; }*node1, node2; ⚫ Here info is the information field and link is the link field. ⚫ The link field contains a pointer variable that refers the same node structure. Such a reference is called as Self addressing pointer.
  • 10. 10 Operator new and delete ⚫Operators new allocate memory space. ◦ Operators new [ ] allocatesmemory space for array. ⚫Operators delete deallocate memory space. ◦ Operators delete[ ] deallocatememory space for array.
  • 11. 11 Traversing a linked list: ⚫ Traversing is the process of accessing each node of the linked list exactly once to perform some operation. ⚫ ALGORITHM: TRAVERS (START, P) START contains the address of the first node.Another pointer p is temporarily used to visit all the nodes from the beginning to the end of the linked list. Step 1: P = START Step 2: while P != NULL Step 3: Step 4: PROCESS data (P) P = link(P) [Fetch the data] [Advance P to next node] Step 5: End of while Step 6: Return
  • 12. 12 Inserting a node into the linked list ⚫Inserting a node at the beginning of the linked list ⚫Inserting a node at the given position. ⚫Inserting a node at the end of the linked list.
  • 13. 13 Inserting node at Front Inserting a node at the beginning of the linked list 1. Create a node. 2. Fill data into the data field of the new node. 3. Mark its pointer field as NULL 4. Attach this newly created node to START 5. Make the new node as the START node.
  • 14. 14 Inserting node at Front ⚫ALGORITHM: INS_BEG (START, P) START contains the address of the first node. Step 1: P new Node; num; START P Step 2: data(P) Step 3: link(P) Step 4: START Step 5: Return
  • 16. 16 Inserting node at Last ⚫ ALGORITHM: INS_END (START, P) START contains the address of the first node. Step 1: START Step 2: P START [identify the last node] while P!= null P next (P) End while Step 3: N new Node; Step 4: data(N) item; Step 5: link(N) null Step 6: link(P) N Step 7: Return Prof. K. Adisesha 75
  • 17. 17 Inserting node at a given Position count+1 next (P) Count 0 Step 3: while P!= null count P End while Step 4: if (POS=1) Call function INS_BEG( ) else if (POS=Count +1) Call function INS_END( ) For(i=1; i<=pos; i++) P next(P); end for new node item; link(P) N [create] N data(N) link(N) link(P) else PRINT “Invalid position” Step 5: Return ALGORITHM: INS_POS (START, P) START contains the address of the first node. Step 1: START else if (POS<=Count) Step 2: P START [Initialize node] P Start
  • 18. 18 Deleting an node ⚫Deleting an item from the linked list: o Deletion of the first node o Deletion of the last node o Deletion of the node at the give position
  • 19. 19 Deleting node from end ALGORITHM: DEL_END (P1, P2, START) This used two pointers P1 and P2. Pointer P2 is used to traverse the linked list and pointer P1 keeps the location of the previous node of P2. Step 1: START Step 2: P2 START; Step 3: while ( link(P2) ! = NULL) P1 P2 P2 link(P2) While end Step 4: PRINT data(p2) NULL Step 5: link(P1) Free(P2) Step 6: STOP