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

2025

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

  1. A.

    O(1)

  2. B.

    O(log n)

  3. C.

    O(n)

  4. D.

    O(n2)

Attempted by 130 students.

Show answer & explanation

Correct answer: A

Array element access by index is a constant-time operation because the memory address can be calculated directly using base_address + (index * element_size). This means regardless of array size, the operation takes O(1) time.

Explore the full course: Tpsc Assistant Technical Officer