Q. What is the time complexity of accessing an element in an ArrayList?

A
O(n)
B
O(1)
C
O(log n)
D
O(n^2)
Solution:

ArrayList provides O(1) time complexity for accessing elements by index due to its array-based structure.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!