Amazon Interview Question for Software Engineer in Tests


Country: India
Interview Type: In-Person




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

I will use a min heap according to priorities in this case.
struct heap
{
int priority
int service
heap *left;
heap *right;
}

or best approach to use a heap is arrays

- DashDash May 31, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Heap is a good choice. If the mapping has to be stored as well, Priority queue can be used.

- arun_lisieux May 31, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@DashDash - using heap wont be gud since they wer refering to infinite service and for which we have to allocate huge size in memory. which is not efficient. i would go for hashing or distributed hashing..

- hello123 June 23, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Maintain a services in use list.
Whenever a service is requested, scan the priority mapping and get the first free service not in the services in use list.
Add this service to the services in use list.
Whenever a service is no longer required, simply delete it from the services in use list.

- Subhajit June 01, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a. What is the datastructure that you will use to store these services. You dont have to store the mapping. Mapping is already stored in the system.
---> Since the lest priority service is to be assigned to any user, a sorted collection is to be used. Best option would be to use a TreeSet

b. Can you write the code for it.
---> User is given the service mapping to first element of this TreeSet (also it is removed from the treeSet), on request for a service.
Make sure that you use synchronized block to synchronize this piece of code, because multiple users will try to access this TreeSet.

Add the service's priority back to the treeset once the user logs out.

c. How will you go about writing automation framework to test it
The above service has to be tested with multiple test cases spanning around no. of users, availability of service etc

- maheshjavaj2ee June 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use doubly link list with hashinig

- Anonymous June 16, 2013 | 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