Facebook Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
@steve: "totally10 Million个entry" ---> what do you mean by this? is the dictionary sorted in increasing order of keys?
As the data is huge(~ 10 GB),I guess, the interviewer is looking for some reader-writer sort of solution(assuming he wants to edit the entries too...)
I guess `个' is a chinese char.
10 Million个entry is actually chinglish which means 10 million entries . .......
1. If dictionary is read only then no protection is needed. It is adding starvation for no good.
- Anonymous October 18, 20122. If read write operation are happening then reader writer will perform better, but still can cause some starvation, but it is better than one mutex.
3. You can have multiple mutex, each protecting subset of hash buckets. 1 mutex protects n buckets. Bucket%n is the mutex you need to grab. 1 mutex for each bucket would cost too much and would become unreasonable.
4. 1 reader writer lock for n buckets. Seems like over engineering to me.