LearnFrenzy
Sign in Take a free test

Data Structures in Java · Data Structures in Java MCQ · Question 1

Cost of reading arr[i] from an array Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

What is the time complexity of reading arr[i] from a Java array of n elements?

  • A O(n)
  • B O(log n)
  • C O(1) Correct
  • D O(n log n)
Correct Answer: Option C

The address is computed directly from the start address and the index, so no searching is needed.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links