Question d’entretien chez Amazon

How would you implement a sparse array (key could be any integer, but only a few would be used) with limited memory.

Réponses aux questions d'entretien

Utilisateur anonyme

7 sept. 2011

A hash table. A linked list is possible but random access isn't efficient

Utilisateur anonyme

23 sept. 2011

need to support efficient sequential read as well. b-tree

Utilisateur anonyme

17 févr. 2012

Hash table

Utilisateur anonyme

19 oct. 2011

Assuming sparse means many values are zero: have 2 arrays: one to store non-zero indexes, the other to store the values at the non-zero index. If queried number is not in the index set, return 0.