The time required to search an element in a linked list of length n is

2025

The time required to search an element in a linked list of length n is

  1. A.

    O (log n)

  2. B.

    O (n)

  3. C.

    O (1)

  4. D.

    O(n2)

Attempted by 404 students.

Show answer & explanation

Correct answer: B

Explanation:

In the worst case, the element to be searched has to be compared with all elements of linked list, so the time complexity is O(n). Option (B) is correct.

Explore the full course: Capgemini Preparation