Google Interview Question for Software Engineer / Developers






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

binary search like tree in dictionary order

- anunymous September 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A hash table since search is fastest O(1)

- DashDash September 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

radix tree. O(1) time.

- memo September 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why do you need store and search a number, all you need is whether a number exists or not, why don't we simply set a bit for a number, you can later check whether that bit is set or not.. It will be O(1), save lot of space.. :-)

- mr.bean October 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It won't save space if the numbers are int64_t. In fact, your bit mask of 2,305,843,009,213,693,952 bytes will probably start a fire.

- Anonymous October 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The proper response is to ask for more information about the input and search patterns.

What is the ratio of numbers to searches? How big is the data set going to get?

If we assume we will get more input numbers then searches (we are online, so the data keeps coming), and that we can't throw latency out the window (again, online) for maximum data sets smaller then memory, a balanced tree might be best. We get consistent insertions. A red-black tree is usually used when insertions > searches. While O(1) for a hash map sounds great, if they numbers keep coming we will keep hitting the rehash limit, which will give you big latency spikes for insertion O(N) vs O(logN) worst case insertion.

If we expect to surpass memory then a B/B+-tree starts to be more appropriate. Or a B/B+-tree on hash(input) if we want to spread out the load at the cost of breaking locality/sortedness.

- Anonymous October 16, 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