Facebook Interview Question: How would you store and searc... | Glassdoor

Interview Question

Software Engineer Intern Interview

How would you store and search 1 million names?


Interview Answer

4 Answers


(Something like this — it's been too long for me to remember the exact questions.)

Start by asking about assumptions: should it be stored in-memory, what matters most: search performance or compact storage, etc.

Interview Candidate on Apr 19, 2012

I guess in this case 'Tries' will be a good structure.. For large data, where lookup will be needed it is better data-structure.
But, I guess you must ask what is the usage scenario :)

Anonymous on Apr 22, 2012

How about B-Tree or Hashtable if space is not an issue?

Anon on May 6, 2012

Tries are good if it can fit into the memory.
Else we can do some preprocessing like sorting the names in persistent storage.
And have the multi level indexing in the main memory.

AB on May 27, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.