Understanding deletion after the given node
This case remains more or less the same as its counterpart in a singly linked list. Here, as an extra step, we also need to update the previous pointer after the deletion operation, but we have already done it for other operations, so you must be familiar with it by now. Let's examine all the cases we need to consider.
1. The list is empty
If the list is empty and contains no elements, we cannot find the given node because it does not exist within the list. Deleting the node after the given node is not possible because there is no reference point within the list to perform the deletion. In this case, we can return the existing head, as the list is empty, and no node needs to be deleted.
Liking the course? Check our discounted plans to continue learning.