Ebay Interview Question for Software Engineer / Developers

Country: United States
Interview Type: Phone Interview

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

Hashcode is generated using hashfunctions. We have different hash functions available, you can simply wiki about it.
Hash functions generate a hash key, we use that hash key as an index to store data in the hash table. But what if two objects have same hash values?
To solve this, one way is to create chain of pointers in one bucket.

Suppose you have three values v1, v2, v3.
Hash values are : h(v1) = 0, h(v2)=1, h(v3) = 0

Hash Table:
[0] -> v1 -> v3
[1] -> v1

This solution works fine for less number of collisions, but when number of collisions grow high, the search starts taking ~ O(n)

Another solution is, Open Addressing:
In this method, if some collision occurs, then instead of making a chain in the bucket, we find next available location in the same hash table, and then we store our value there.

For the example above:
[0] -> v1
[1] -> v2
[2] -> v3

We also have different type of methods to search next available position in the hash table.
1. Linear Probing: if the hash value is h and it collides then check at h+1
2. Quadratic Probing: if the hash value is h and it collides then increase the hash by 1^2, 2^2 , 3^2 and so on.

I think this should suffice.

- HauntedGhost March 07, 2013 | Flag Reply

Add a Comment

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


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


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