Junior — Middle
How to determine the asymptotic complexity of the operation of reading an element in a Python list?
sobes.tech AI
Answer from AI
In Python, a list is implemented as a dynamic array. This means that access to an element by index occurs in constant time — O(1).
Example:
my_list = [10, 20, 30, 40]
element = my_list[2] # access to element with O(1) complexity
Thus, the operation of reading an element by index in a Python list has an asymptotic complexity of O(1).