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?

  1. A.

    O(n)

  2. B.

    O(log2 n)

  3. C.

    O(logn)

  4. 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)

Explore the full course: Gate Guidance By Sanchit Sir