Question discussion

Calculate the worst-case time complexity of searching for an element in a singly linked list with 'n' elements.

359083Medium DSSSB TGT Computer Science 0 replies 0 views
0
Calculate the worst-case time complexity of searching for an element in a singly linked list with 'n' elements.
  • AO(log 1)
  • BO(n)
  • CO(1 log)
  • DO(1)
Correct answer: B

Explanation

In the worst case the element is the last or absent, so every node is visited: O(n).

Discussion 0

Nobody has replied yet. Start the discussion!