Open In App

GATE | CS 2022 | Question 15

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?

(A)

The best algorithm for the problem takes  time in the worst case

(B)

The best algorithm for the problem takes  time in the worst case. 

(C)

The best algorithm for the problem takes  time in the worst case

(D)

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


Answer:(A)
Explanation:

The given linked list is a reverse linked list and the best algorithm in reverse linked list takes  time in the worst case. So, option A is the correct answer. 


Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :
Uncategorized