592 views
0 votes
0 votes

15 randomly generated numbers can be sorted preferably by:

heap sort 

insertion sort 

bubble sort

1 Answer

1 votes
1 votes

-Bubble sort time complexity is O(n2)

-Insertion sort worst case time complexity=O(n2) best case time complexity=O(n)

in insertion sort best case is possible only when most of the elements are already sorted.

-Quicksort best case and average case time complexity=O(nlogn)    worst case time complexity=O(n2)

If the randomly generated numbers in any case are already sorted then the time taken by quick sort will be O(n2)

-but heap sort will always give a  running time of O(nlogn) so heap sort should be used
 

edited by

Related questions

1 votes
1 votes
1 answer
1
LavTheRawkstar asked Sep 11, 2017
2,396 views
What is the ascending wise order of sorting algorithms which takes least time and least space to sort the elements?
0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
4
shikharV asked Jan 19, 2016
677 views
Please explain how heapsort will give us best results?