A sorted array with binary search allows you to do things
efficiently that you cannot do efficient with hashes.
For instance, finding the rank of the element you are searching for, if the searched element isn't in the set,
find the largest element in the set that is smaller (nearest
neighbour), or doing a range query (given two values, give
all elements of the set between those values).
Hashes are fast to do member queries with, and to do updates,
but hashes are very limited in what you can do with them.
Abigail | [reply] |