Consider the problem of reversing a singly linked list. To take an example,…

GATE · 2022 · CS · Computer Science & IT

Consider the problem of reversing a singly linked list. To take an example, given the linked list below,

the reversed linked list should look like

Which one of the following statements is TRUE about the time complexity of algorithms that solve the above problem in O(1) space?

  1. A.

    The best algorithm for the problem takes \(\theta(n)\) time in the worst case.

  2. B.

    The best algorithm for the problem takes \(\theta(n log n)\) time in the worst case.

  3. C.

    The best algorithm for the problem takes \(\theta(n^2)\) time in the worst case.

  4. D.

    It is not possible to reverse a singly linked list in O(1) space.

Attempted by 728 students.

Show answer

Correct answer: A

The worked solution is available to enrolled students.

Video solution available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…