How would you implement a sparse array (key could be any integer,
but only a few would be used) with limited memory.
Risposte di colloquio
Anonimo
7 set 2011
A hash table.
A linked list is possible but random access isn't efficient
Anonimo
23 set 2011
need to support efficient sequential read as well. b-tree
Anonimo
17 feb 2012
Hash table
Anonimo
19 ott 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.