Hi ruby fans,

I have a question about algorithm efficiency.

I have used hash in my ruby program. It worked fine. However, I found
that the memory consumed by a hash is tremendous. While the hash file is
stored on disk (using pstore) it is merely 100-200KB, but in memory, it
consumes apporximately 5-10 Megabytes! I don't know if it is related to
the cache algorithm used by ruby?

I tried to reduce this memory requirment and thought of using Binary
Tree. Just did some test in Delphi, it seems good. I loaded an English
dictionary of about 1M (90000+ lines) it just took about 6-8M of memory,
seems much better than hash.

Now my question is, since hash is O(1) and BTree is O(LOG(N)), does it
mean that hash is born to be less storage-efficient than BTree? How can
I get the best of both BTree and hash?

Thanks a lot.

Shannon