As the title says, I was wondering what the time complexity of the contains() method of an ArrayList is.
contains()
ArrayList
O(n)
The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation.
size
isEmpty
get
set
iterator
listIterator
add
http://download.oracle.com/javase/6/docs/api/java/util/ArrayList.html
1.4m articles
1.4m replys
5 comments
57.0k users