What is the time complexity of accessing an element in an array?
- O(1)
- O(log n)
- O(n)
- O(n^2)
The time complexity of accessing an element in an array is O(1) or constant time. This is because arrays provide direct access to any element using its index, and the access time remains constant regardless of the array size.
Loading...
Related Quiz
- Which of the following elements is used to define a table row in HTML?
- In a web application experiencing slow load times, what steps would you take to identify and resolve performance bottlenecks?
- Which JavaScript framework is known for its simplicity and ease of integration into existing projects?
- The HTML5
- What does the title attribute do in HTML?