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

  • A O(1)
  • B O(n)
  • C O(log n)
  • D O(n log n)

Explanation

Because array elements sit in contiguous memory, the address of any element is computed directly from its index, giving O(1) access.