Amazon Interview Question

Find the most frequent 3-page sequence in a web log.

Interview Answers

Anonymous

Apr 21, 2010

Did you find the answer for this? I am really interested in this answer and would greatly appreciate it if you can provide some pointers.

Anonymous

Jul 14, 2010

MY solution would be to sort the web log by date, and IP. If the user made less than 2-page sequence, then remove that IP. For each 3 possible sequence, add it to a data structure. If the sequence already exists, then increment the count of the sequence. In the end, you can do a search on the data structure to find the 3-page sequence that appeared the most frequent.

Anonymous

Sep 21, 2011

Could you use a hash table where the key is derived from the sequence and the value is the number of times it occurs?