Interview Question


Country: United States




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

Better use counting or radix sort for string sorting.
If you want to use selection sort than simply replace the comparison with you custom comparator function which compares to strings based on ascii values of characters starting from 0th place.

- Cerberuz September 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

How will you use counting sort for strings? Radix sort is OK.

- eugene.yarovoi September 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

The original question is what i have written.It has to be solved by selection sort and using language C.

- BeautifulCode September 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@eugene.yarovoi, using R-B Tree we can store count of each string directly. This will give O(n*log(n)*log(n)) implementation. If we use hashing for counting, it will give O(n*log(n)) solution. { obviously i am ignoring string lengths in time complexity + overhead of collision avoidance }. So, it won't be better than radix sort but will outperform selection sort.

- Cerberuz September 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about the efficiency if implemented using linked-list instead of array version???

- BeautifulCode September 10, 2012 | 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