Amazon Interview Question
SDE1sCountry: United States
Interview Type: In-Person
@puneeth.nie.s there are many sections on the advertisement page(here the home page
"amazon.in",correct me if i'm wrong ) which particular section you are talking about ,there is a suggestion list which shows products according to your previous search /buy /interest and many more , are you talking about that or the advertisement slider showing different offers?
Use browser cache to suggest products searched by user.
For suggesting similar products bought by other users, maintain a weighted graph with products as nodes. Weight will refer to the number of customers who bought the two connected products.
Product nodes can be stored in hashmap(to search a product in graph in O(1) time).
To suggest k similar products, use a k size min heap.
caution long answer below:
- saurabh March 16, 2016okay at last i got some time to answer your question .
LRU page replacment,mostly used in operating system but you see it doesn't make sense to me for a website with millions of products ,i mean indexing each product for a single customer and manipulating those indexes relevant to each customer not efficent neither cool.
from my point of view there are three ways to look for at problem
1. Either they use a collection of separate column values to store
products you search or view
problem:-
but com'on how novice is it ,and its not a college project which you are doing just because you are suppose to ,its pure bussiness so this is neither cool not flexible ,and yes cool here means its doesn't seems geeky.
2. Use Browser caches to store and retriev your past history to show suggestions
problem :-
its a good way to do such thing and cool as well but you see broswer caches are small data stores and storing some user related data on user machine is not at all proffesional in terms of bussiness.
so its cool but not flexible for a complex structure like amazon
3.combination of first and second points (i.e columns + browser caches)
there's a catch here that instead of columns amazon may use a graph based database (i.e google for neo4j) using the caches data it can further make nodes and a simple dfs travesal can provide a collection of connected products and using counting inversiopn techinques can give you the data for people who viewed this also viewed this product and whalaaaaaaa you have it..
so these are my point of view on how they would be implementing it ,i would love to have a healthy discussion or re-explanation in case you need it
(note : these are my own point of views it doesn't resembels any of amazons perspective )