Amazon Interview Question
Country: India
Was this question asked for a Technical Lead or Architect role?
@sk: could you please elaborate on the answer.
PS: I have a F2F in Amazon next week for a SDE1 or SDE2 role. A good answer to this question would be much appreciated
If you are going to interview for tech lead or architect, you probably should know this already!
1.we will use B+ tree, cached data is stored at leaf which will be inside physical memory.
- sk June 06, 2012Since retreaving of data will become fast only latency will be there due to disk access.Since in B+ tree ,height should be minimum at disk level so latency will be nearly equal to 1 disk operation(if thr would be data at 1 height inside physical memory.)
2nd way :- first we can keep track for data by using LinkedHashMap in main memory. If data is not found and if key exist in the Map then will do search in Physical memory(db) and retrieve data according to that.