Insertion, Deletion, Update, and Copying Operations
Presented by:
Hashim Shaikh (24CO107)
Mohammad Ragib (24CO108)
Shoaib Shaikh (24CO109)
Introduction to Singly Linked List
• - A singly linked list is a linear data structure.
• - Consists of nodes where each node contains:
• • Data
• • Pointer to the next node
• - Dynamic in nature, unlike arrays.
Structure of a Node
• - Each node contains:
• • Data field (stores value)
• • Pointer (stores the address of the next
node)
• - Example diagram of a node.
Types of Operations
• - Insertion
• - Deletion
• - Update
• - Copying
Insertion Operation
• - Insert at the beginning
• - Insert at a specific position
• - Insert at the end
• - Algorithm & example for each type.
Deletion Operation
• - Delete from the beginning
• - Delete from a specific position
• - Delete from the end
• - Algorithm & example for each type.
Update Operation
• - Find the node to update.
• - Modify the data field.
• - Algorithm & example.
Copying a Singly Linked List
• - Create a new list.
• - Traverse the original list.
• - Copy nodes one by one.
• - Algorithm & example.
Advantages & Disadvantages
• - Advantages:
• • Dynamic size
• • Efficient insertions and deletions
• - Disadvantages:
• • Extra memory for pointers
• • Sequential access required.
Conclusion
• - Recap of insertion, deletion, update, and
copying.
• - Importance in programming and data
structures.
• - Questions & Discussion.
Practical Applications of Singly
Linked List
• - Used in dynamic memory allocation.
• - Implementing stacks and queues.
• - Managing symbol tables in compilers.
• - Undo functionality in software.
References
• - Data Structures and Algorithms textbooks
• - Online coding platforms (GeeksforGeeks,
LeetCode)
• - Lecture notes and programming
documentation.
Code Implementation (C)
• Example of inserting a node in a singly linked
list:
• #include <stdio.h>
• #include <stdlib.h>
• struct Node {
• int data;
• struct Node* next;
Code Implementation (Python)
• Example of inserting a node in a singly linked
list:
• class Node:
• def __init__(self, data):
• self.data = data
• self.next = None
• def insert_at_beginning(head, new_data):