Data Structures · Question 4 · Easy

What is the time complexity of accessing the element at index i of an array?

  1. O(log n)
  2. O(1)
  3. O(n)
  4. O(i log i)
Answer and explanation

Answer: B. O(1)

Explanation: Array elements are stored contiguously, so the address of arr[i] is base + i × element size, computed in constant time.

Previous: Starting with an empty queue: enqueue(A), enqueue(B), enqueue(C), dequeue()… · Next: Which data structure is used to implement Breadth-First Search (BFS) of a graph?

Practise data structures

Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.

More data structures questions

More technical & programming practice

Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge