Amazon Interview Question for Software Engineer / Developers

Country: United States
Interview Type: Phone Interview

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

In short:
Mergesort is a sorting algorithm that follows the paradigm of: divide and conquer:

1) recursivly split the array in 2
2) until the array length is 1 ( or the pointers start and end are equal)
3) merge the sorted array an return the array sorted

public static char[] mersort(char str[], int start, int end){
		if(str.length <= 1 ){
			return str;

			int middle = (end-start)/2;
			char[] first_half = getArray(str,start,middle);
			char[] second_half = getArray(str,middle,end);
			char [] l1 = mersort(first_half,0,first_half.length);
			char [] l2 = mersort(second_half,0,second_half.length);
			return mergeArrays(l1,l2);

HashTable: Is an implementation of a Dictionary where you MAP Key and Values.
You need the Key's hashcode to located the bucket where the value is going to be store.
The hashcode must be well implemented shuch that It will always return the same value for the same key.
equals method should also be implemented in case of collision, so we can iterate over the list of values at the same bucket.

There are many implementation of MAP, one of them are hashtable which are thread safe. HashMap is similar but is not thread save.
There are other implementations where the key as store in oreder, so implemented the MapSorted such as treeMap.

hashtable operation runs on constant time O(1) (AVG), such as get, put, and contains.

There are many other things you can talk about hashing, like hashing functions, hashCode for Object class, and some others.

- .·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º> November 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

Stop posting incorrect answers on purpose @Anonymous

- varun sharma ( CEO of ) November 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
of 1 vote

Very common sde questions. Try it!

- unicorn November 16, 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