PanTau
PanTau

Reputation: 73

Fastest Search in ArrayList<String>(a sorted)

I am interested in the fastest search in sorted ArrayList of String. What is a fast way?

I am using method contain, but i think, there is a better way.

What about 2 threads? One from the front and second from behind.

List sorted contains elements of the same length.

aaa
bbb
ccc
ddd
eee
fff
ggg
.
.

What what is your opinion ?

Upvotes: 1

Views: 485

Answers (1)

Rohit Jain
Rohit Jain

Reputation: 213233

This can be done with binary search. Java provides Collections.binarySearch().

Upvotes: 6

Related Questions