Apple Interview Question for Senior Software Development Engineers


Country: United States
Interview Type: Phone Interview




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

I think more than the answer, the reason would be important. Quick sort for example is important because its average runtime is O(nlog(n)) and in most cases its better than other logarithmic algorithms ( Merge Sort and Heap Sort ). I would ask him though, why would you want to stop at implementing just one algorithm. How about an API that can use sort based on input size ( strategy design pattern ); because for different values of n different sorting algorithms can be usefule

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

Quick sort algorithm, because it is best sorting algorithm. Implement in C++.
Please comment if above mentioned answer is not appropriate.

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

I said same and then he asked why quick sort is best?

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

for given size if it is less than, said 10, go for simple sort algorithm like insert, more than that, go for Quicksort.

Reason for Quicksort:

1. it is the fastest in real world (although theoretically merge sort/heap sort could always provide NlogN while Quicksort in worst case is N*N, but that rarely happen).

2. Quicksort doesn't need additional space compared to Merge sort.

- groomnestle December 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Bad thing about Quicksort: It is not a in place sorting algorithm (meaning if two elements are already sorted at some point they could be swapped again later before algorithm finally ends).

- groomnestle December 04, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

That's not the definition of "in-place sorting". In place means that all times during the execution of the algorithm, it uses a constant amount of space, not a function of N.

- Anon January 04, 2014 | Flag


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