What is the time complexity of accessing an element in an array?

  • O(1)
  • O(n)
  • O(log n)
  • O(n log n)
Option 1, O(1), represents constant time complexity. Accessing an element in an array by its index takes the same amount of time, regardless of the array size. Hence, it is independent of the array's size, resulting in constant time complexity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *