Adobe Interview Question
SDE1sInterview Type: Phone Interview
As the storage size will be limited, we don't want to keep on storing entire browsing history.
1) We can use circular array of limited size (say 1000) and then keep on updating the queue, so the final 1000 will contain latest browsed pages-in order of browsed date and time.
2) For displaying history, process the array from end -> start ( in reverse order) , so printing recently browsed page first.
3) We may like to write the older history record to file. So, don't discard the updated urls at the end of queue, but keep on inserting them on fixed size queue.
4) Once the queue is full, create new queue to push the pages.Write the entire old queue data to file and destroy it. [ using queue to do bulk IO instead of small writes ]
5) When user want to load older pages, read the data from file.
6) Here, to maintain the order, we have to read the entire file and print it in reverse order to display by access time.
We can keep the data structure in LRU cache type architecture. As soon as someone will search any existing link, it will come as front element of doubly link list.
- Phoenix July 28, 2015