Suggest a DS for web server to store history of visited pages. The server must maintain data for last n days. It must show the most visited pages of the current day first and then the most visited pages of next day and so on.
Approach:
Let n be the number of days of data that we want to maintain.
We create a Map of dayMap<Integer, HashMap<pageHash, Count>>
in dayMap key is the day number and the value is another map where key is the hash of the page link and value is the count of the visits.
we can do the eviction based on the LRU.
The problem gets more interesting when there are more than 1 web servers involved.
In that case we still have to maintain the map, but we have to collate the results of a particular data at a central node.
No comments:
Post a Comment