Interview Question


Country: India




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

If you're trying to sort by phone number, radix sort is the best algorithm.

- Roger December 29, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The race is between :

d * n  ,  n * log ( n )

where d is the number of characters we are using for entries, and *n* is no of entries.
For a reasonable size value of *d* being 30, for that n, n*log(n) is smaller.
Thus, you probably should go with a comparison sort.

- NoOne December 30, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Roger
But if all the digits of telephone number are distinct then wont the time complexity drop to O(nlogn) which is same as comparison-sort. Please correct if I am wrong

- Ankita December 30, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

i think hashing is best for it . because it's complexity is O(1).

- Anonymous December 31, 2016 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

why can't Quick sort?

- Raj December 30, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bucket sort with 1 bit for each bucket. O(n) time complexity.

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

Bucket Sort with 1-bit bucket. O(n) time complexity.

- ExK January 02, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Radix sort is much more efficient than ant other sorting techniques like quick,merge etc.
having less time complexity

- lavakumarfire999 January 02, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Isn't a telephone directory already sorted?

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

Binary search

- MikeM January 14, 2017 | 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