Skip to content

Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node Q from the list?

  1. A.O(n)
  2. B.O(log2 n)
  3. C.O(logn)
  4. D.O(1)
Show answer

Answer: D. O(1)

Copying data from the succeeding node into Q and bypassing the succeeding node allows deletion in O(1) time.