The problem suggests that the node to be deleted is known and a pointer to the node is available.
To remove a node and join the previous and next node together, you need to know their pointers. In a doubly linked list, both pointers are available in the node to be removed. The time complexity in this case is constant, i.e. O (1).
If the pointer to the previous node is unknown in a simply linked list and can only be found by moving the list from the head until it reaches a node that has the next node pointer to node that should be removed. The time complexity in this case is O (n).
In cases where the node to be deleted is known only by value, the list needs to be searched and the time complexity becomes O (n) in both single and doubly linked lists.
Raj
source share