The time required to search an element in a linked list of length n is
2008
The time required to search an element in a linked list of length n is
- A.
O (log n)
- B.
O (n)
- C.
O (1)
- D.
O (n2)
Attempted by 208 students.
Show answer & explanation
Correct answer: B
To search for an element in a linked list, we must traverse the nodes sequentially starting from the head. Since there is no direct access to arbitrary elements, we may need to visit every node in the worst case. Therefore, the time complexity is O(n).
A video solution is available for this question — log in and enroll to watch it.