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

Options

  • A. O(n)
  • B. O(log n)
  • C. O(1)
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. O(1)

Detailed Explanation

Correct Answer: C. O(1)

Explanation: Array elements can be accessed directly using their index.

  • The memory address is calculated using the base address and index.
  • No traversal is required.
  • Therefore, random access takes constant time O(1).