Alex Rivera | Logout

Hash table vs Balanced binary tree

Asked 2011-01-31T00:00:28.253
49

What factors should I take into account when I need to choose between a hash table or a balanced binary tree in order to implement a set or an associative array?

Edit
Report

1 Answer

3

To add to the other great answers above, I'd say:

Use a hash table if the amount of data will not change (e.g. storing constants); but, if the amount of data will change, use a tree. This is due to the fact that, in a hash table, once the load factor has been reached, the hash table must resize. The resize operation can be very slow.

answered 2011-01-31T16:18:43.687

Your Answer