← BYTES
Algorithms·Starter·Ref: 12.1.3
What is the time complexity of accessing an array element by its index (e.g., `arr[5]`)?
Have a question about this video? Mention reference 12.1.3 when you contact us.
a.O(n)
b.O(log n)
c.O(n^2)
d.O(1)
Arrays store elements in contiguous memory, so the address of any index can be computed directly via arithmetic (base address + index * element size) -- a constant-time O(1) operation regardless of array size, unlike a linked list, where reaching a given position requires traversing from the start.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES1213#Algorithms