Domanda di colloquio di Amazon

Implement a reverse hash table

Risposte di colloquio

Anonimo

30 lug 2013

As a way to make it as space-conserving as possible, the key->value pair can be inserted at the hashes of both the key and value. This would allow you to both differentiate a forward and reverse lookup, and use only a single additional pointer of space per entry.

1

Anonimo

2 apr 2013

This was easy enough but I somehow had seen this done with just one hash table and that isn't really possible. Should have gone with the simple, direct approach and optimized later.

Anonimo

12 lug 2013

Can you be more precise regarding the meaning of a "reverse hash table"

Anonimo

17 lug 2013

Say its a table T like this: T[1] = "Bob" T[2] = "Sally" T[3] = "Greg" Then it should also be possible to do: T["Bob"] = 1 T["Sally"] = 2 T["Greg"] = 3 Keys can be values and values can be used as keys