Deletion in Linked List Data Structure | DSA Tutorials YASH PAL, 12 May 20204 May 2026 Deletion in Linked list – As we know, for performing operations on the linked list we need to find the reference to the node of the list. So, to delete a node from any position in the linked list, we need to first find the reference to the node.And if you don’t know how to find the reference of a node in the linked list, then first complete reading this post – Operations on a linked listDeletion in Linked List Data StructureDeletion of the first nodeDeletion of the only nodeDeletion between the nodesDeletion at the end of the listDeletion of the first node from the linked listAs you see, we have a linked list that contains 5 items in it.Figure 1: Deletion of the first node from the linked listTo delete the first node of the list, we need to point the start variable of the linked list to the second node of the list.Figure 2: Deletion of the first node from the linked listSo now the first node of the linked list is deleted.Figure 3: Deletion of the first node from the linked listdef delete_first_node(self): if self.start is None: return self.start = self.start.linkdef delete_first_node(self): if self.start is None: return self.start = self.start.linkDeletion of the only node from the linked listIf we have a list that has only one node, as shown in Figure 4.Figure 4: Linked List with only a NodeThen, to delete the only node of the list, we store the null or None value in the start variable.Figure 5: Deletion of the only node from the linked listSo now our list becomes empty.Figure 6: Deletion of the only node from the linked listself.start = Noneself.start = NoneDeletion between the nodes of a linked listTo delete a node between the nodes of the linked list, first, we need to find the reference of the predecessor of the node that we want to delete. Like in the example given below, we want to delete the second and fourth nodes. So we want to delete the node that contains the value 30.So we need to find the reference to the node that comes before the node that contains the value 30.Figure 7: Deletion between the nodes of a linked listThen we refer the p node to the node that comes second after the node p, as you see in Figure 8.Figure 8: Deletion between the nodes of a linked listNow the node is deleted from the list.Figure 9: Deletion between the nodes of a linked listDeletion at the end of the linked listTo delete the last node, we need a reference to the second last node of the linked list, as shown in Figure 10.Figure 10: Deletion at the end of the linked listAfter that, we set the linked part of p to null or None.Figure 11: Deletion at the end of the linked listSo now the last node of the linked list is deleted.Figure 12: Deletion at the end of the linked listdef delete_last_node(self): if self.start is None: return if self.start.link is None: self.start = None return p = self.start while p.link.link is not None: p = p.link p.link = Nonedef delete_last_node(self): if self.start is None: return if self.start.link is None: self.start = None return p = self.start while p.link.link is not None: p = p.link p.link = NoneData Structures & Algorithms Tutorials for Beginners Computer Science Tutorials Data Structures Tutorials computer scienceData StructureDSA Tutorials