Let P be a singly linked list. Let Q be the pointer to an intermediate node x…
2004
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?
- A.
O(n)
- B.
O(log2 n)
- C.
O(logn)
- D.
O(1)
Attempted by 600 students.
Show answer & explanation
Correct answer: A
option A is correct as , we need to traverse upto q-1 node to delete the Qth node .hnce the time complexity goes to O(n)