Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

Maintain the items in order of access in a doubly linked list, along with pointers to the first and last nodes.

Use a hash table with keys = items, values = location in linked list.

When you access an element, delete it from the linked list and re-insert it at the beginning. When you remove an element, delete it from the end and remove it from the hash table.

- Anonymous March 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

very nice!

- shark January 04, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You could use circular linked list and save some space.

- Jaffa April 28, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Cache is implemented by a splay tree . With every Node we have a timer which contains the last time it was accessed !

- JD February 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Using splay tree you are supposed to get the most recently used ones at the top levels. Does the splay tree help you find least recently ones conveniently?

- Anonymous February 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

www,vldb,org--conf--1994--P439,PDF

- Anonymous February 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Shouldnt a hash in association with a linked list do the required. The algorithm in the link seems to be very sophisticated and is going above my head at this point in time.

the input to the hash function shall be similar to how the memory calls for a page. A null pointer shall indiacte a page fault (O(n)) and o.w. it will point to a valid page in the memory.
Moving the page would be a mere pointer manipulation with O(1). IF somebody understands the algoirthm/paper associated with the link, please take some pain to explain it. Thanks in advance

- hary February 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your approach does not seem to consider the eviction of the "LRU" hash entry problem. The real problem to solve for this question is how to identify the Least recent used hash entry- ideally in constant time so that any time spent on a cache miss is mainly the time required to load the new entry into the cache.

- aquila.25 March 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use Min heap , very easy

- Nishant February 25, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More