Question Detail

COS 102 test topic Objective Question

Question

What is the time complexity required to access an element in an array when its numerical index is known?
Options
A O(1)
Correct Answer
B O(n)
C O(log n)
D O(n^2)
Correct Answer

Option A is the correct answer.

Detailed Explanation

Array indexing calculates the base pointer offset mathematically in constant time O(1).

Hint

No hint available

Question Info