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:
- A.
O(n log n)
- B.
O(log n)
- C.
O(n)
- 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.