retagged by
479 views
0 votes
0 votes
To sort the following numbers which algorithm will suit the best                                            

(i) 1 to 100 integers    (ii) 0 to 1000000 integers                                                                                          

a)bucket sort for both                                                                                                                   

b)  (i)radix sort   (ii)quick sort                                                                                                      

c)  (i)quick sort   (ii)merge sort                                                                                                    

d)  (i) merge sort  (ii)quick sort
retagged by

1 Answer

0 votes
0 votes
here for the bucket sort it takes O(n2) in worst case but the quick sort  takes O(n2) and merge sort takes O(n log n) but the radix sort takes O(n)for small elements and for larger digits it takes O(nlogn)

so as(1-100) are have small digit value radix sort is best with O(n) and quicksort takes O(nlogn) small inputs

for(0 to 1000000 integers ) merge is best

with the given options we can go for  (i)quick sort   (ii)merge sort      

finally ANS:-  is option   (c)  (i)quick sort   (ii)merge sort