Junior — Middle
What is the time complexity of reading an element in a singly linked list?
sobes.tech AI
Answer from AI
The time complexity of reading an element in a singly linked list is O(n), where n is the index of the element.
This is because accessing an element by index in a singly linked list requires traversing from the beginning of the list to the desired element, as there is no direct access by index.
For example, to get the 5th element, you need to traverse the first 4 elements sequentially.