Tripadvisor Interview Question

Implement LRU algorithm; Write code to implement a general Binary Search Tree

Interview Answers

Anonymous

Sep 24, 2010

a few details about the above post: the linked list should be doubly linked, so that remove is not O(n) the id should be some sort of hash of the page

1

Anonymous

Jan 12, 2010

LRU: Hashtable is used to hold pages IDs as keys and pointers to the appropriate page. All the pages are in a linked list. Anytime we access some page, it is placed at the head of the list. This way pages to be removed are always at the tail of the list. Each page should know its ID, so that we could remove it also from the hashtable.

1