Hi,
We all know that a hash table has O(1) time for both inserts and look-ups if the hash function was well chosen. So, what are the reason we want to use Binary Search Tree? Just because a perfect hash function was hard to design?
Here how I come up with this question?
I notice that Standard C++ STL has set
and map
which are implemented with Binary search tree ,but has no hash (not talking about non-stardard hash_set
, hash_map
). While, Ruby has only Hash
. I want to understand the rational behind this difference.