Question

In a doubly linked list with n nodes, what is the time complexity to delete a node given only a pointer to that node (not the head), and why does this differ from a singly linked list?

A O(n) for both singly and doubly linked lists
B O(1) for a doubly linked list and O(n) for a singly linked list
C O(1) for both
D O(log n) for doubly linked list; O(n) for singly linked list
E Deletion given only a node pointer is impossible in both cases
Practice Next

Hey! Ask a query