The time complexity of searching an element in linked list of length n will be:

2020

The time complexity of searching an element in linked list of length n will be:

  1. A.

    O(n log n)

  2. B.

    O(log n)

  3. C.

    O(n)

  4. D.

    O(n²)

Attempted by 540 students.

Show answer & explanation

Correct answer: C

To search for an element in a singly or doubly linked list of length n, you must traverse it sequentially starting from the head node. In the worst case (if the element is at the end or not present), you have to check all n nodes. Therefore, the time complexity is O(n). Thus, Option C is correct.

Explore the full course: Niacl Ao It Specialist