Question d’entretien chez Yelp

If memory is limited, which data structure is better: hashtable or binary tree?

Réponses aux questions d'entretien

Utilisateur anonyme

27 déc. 2010

binary tree is better if memory is limited...

2

Utilisateur anonyme

7 oct. 2011

To add more to the above answer. Binary trees use memory in proportion to the data that is to be stored - the data and links. For a hash table, if the hash function has a huge range, you will have to allocate an array that has an entry for each number in the range. You could potentially store far lesser number of elements than the range.

1