Question 17
Back to Exercise
You already hold a reference to a node in a doubly linked list. What does it cost to remove that node?
- A O(1) Correct
- B O(log n)
- C O(n)
- D O(n²)
Correct Answer: Option A
Point node.prev.next at node.next and node.next.prev at node.prev. A singly linked list would first need to find the previous node: O(n).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!