Algorithms and Data Structures · Junior · Question 6 of 75
What is the complexity of reading arr[i] from a JavaScript array?
- ✓Correct answer: O(1)
- 2O(n)
- 3O(log n)
Explanation
Access by index is constant time: the engine computes where the element is instead of walking through the array. That's the main advantage of arrays over linked lists.