Reputation: 13367
I have a lot of short arrays(10-20 elements). What is best way(i mean speed) to found one element in each array? Binary search, tries, hashtable etc?
Upvotes: 0
Views: 145
Reputation: 171206
Measure at least three approaches:
Measure them for different input sizes and choose the best method at runtime depending on the size of the array.
You could also investigate perfect hashing which trades a big upfront calculation that only needs to be done once for very fast lookup.
Upvotes: 1