Hide Index
- Understanding insertion at beginning
- Insert at beginning
- Understanding insertion at end
- Insert at end
- Understanding insertion after the given node
- Insert after the given node
- Understanding insertion before a given node
- Insert before the given node
- Understanding insertion at a given distance
- Insert at given distance
- Understanding deletion of first node
- Delete first node
- Understanding deletion of last node
- Delete last node
- Understanding deletion by given data
- Delete node with given data
- Delete nodes with given data
- Understanding deletion after a given node
- Delete node after the given node
- Understanding deletion before a given node
- Delete node before the given node
- Understanding deletion of the given node
- Delete the given node
- Understanding deletion at a given distance
- Delete node at given distance
Understanding insertion at end
When inserting at the end of a doubly linked list, we must access the linked list's tail node. Fortunately, we have direct access to the list's tail node in a doubly linked list. This makes insertion at the end quite similar to insertion at the beginning. There are two cases to consider when inserting at the end of a doubly linked list.
1. The list is empty
In this scenario, if the linked list is empty, the head will be null. We need to initialize the head node of the linked list and ensure that the next and previous pointers of this newly created head node are null, as this node is also the tail node of the list.
Liking the course? Check our discounted plans to continue learning.