Amazon Interview Question for Software Engineer / Developers






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

For fast retrieval and search of zip codes, I will go wid Trie Tree

- Aryan October 30, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

any good pointers to trie trees ? Is that the same as radix tree ?
Isn't a hash table better than trie ?

- Anonymous November 03, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would use array.

- lzhongsh November 01, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How about hash table ?

- JD November 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What are the requirements?
Secondary storage (like disk) needed? What is the read/write/query scenario.. etc.

- Anonymous November 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In my opinion: when it is asked about "data structures", they mean to store stuff in main memory. So a Trie would certainly be the best in this case, where the tree height will be no more than the length of the data (zipcode or SSN). The height will be even shorter if we take multi-stride tries.

http://en.wikipedia.org/wiki/Trie

Arrays will take O(n) comparisons to retrieve data, and hashtables waste storage space.

- Som November 03, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just because it's an interview question does not mean we need to INVENT some COOL answer. I love it when interviewers use such questions to spot people who have memorized stuff.

- burdell November 04, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

These codes are derived from multiple inputs like state+area
one state we have multiple areas

In this case, we have Hash of Hash. Each row signify State.

- Anonymous November 07, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Trie it is!

- Anonymous November 08, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Set associative mapping method is better, in this case.

- Anonymous November 13, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

you have to ask yourself what the data will be used for. SSN and area code are will probably be assigned to a person with a potential personID. Given a personID you should be able to quickly retrieve his/her data. Hash table would be ideal. arrays would work if the index of the element is also the ID passed in.

- alex g January 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A Trie can be used here as SSNs and ZIP codes share a huge number of prefixes, thereby maximizing space utilization.

- Ace February 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Before going into technical details I would ask if we have clearance from the Legal Department to store SSNs ;)

- cristi.vlasceanu May 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Brilliant point!

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

awesome dude!!!

- smart-ass July 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Cristi:
I think we don't have the requisite clearance for storing the SSNs, so that's the "Smart Answer" the interviewer is expecting.
Answer it and get hired!

- Anonymous September 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

TRIE

- Anonymous January 15, 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