1.

Which of the following sorting techniques is most efficient if the range of input data is not significantly greater than a number of elements to be sorted?(a) selection sort(b) bubble sort(c) counting sort(d) insertion sortThe question was posed to me in an internship interview.This interesting question is from Sorting in portion Sorting of Data Structures & Algorithms II

Answer»

The correct choice is (c) counting sort

The BEST explanation: Time complexity of counting sort is given as O(N+K) where n is the number of input elements and k is the range of input. So if range of input is not significantly LARGER than number of elements in the array then it proves to be very efficient.



Discussion

No Comment Found

Related InterviewSolutions