
Shao X. answered 05/26/19
Software Engineer at Amazon
Binary search trees:
For using binary search trees, you need to make sure your customer ID is sortable. And to look up an ID, the response time is log(n). Plus you need to make sure your tree is balance while inserting new customer into the data structure.
Hash Table:
There are multiple ways to create a hash table. For instance, you can use array approach and map the object key into the bucket index, as long as you provide a hashCode() and equal() methods in your class.(The issue is, two object may have a same key, (you can do chaining, rehash, or multi-level hash.) If you can prevision your keys size, you can avoid collision. Getting a key in HashTable is O(c) cause your hashCode() provides the address of the object location in memory.