Asked • 05/22/19

Hash tables versus binary trees?

When implementing a dictionary ('I want to look up customer data by their customer IDs'), the typical data structures used are hash tables and binary search trees. I know for instance that the C++ STL library implements dictionaries (they call them maps) using (balanced) binary search trees, and the .NET framework uses hash tables under the hood.> What are the advantages and disadvantages of these data structures? Is there some other option that is reasonable in certain situations?Note that I'm not particularly interested in cases where the keys have a strong underlying structure, say, they are all integers between 1 and n or something.

1 Expert Answer

By:

Shao X. answered • 05/26/19

Tutor
4.9 (34)

Software Engineer at Amazon

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.