899 views
0 0 votes

15 randomly generated numbers can be sorted preferably by:

heap sort 

insertion sort 

bubble sort

1 Answer

1 1 vote

-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
Position:
Show:

Related questions

1 1 vote
1 1 answer
3.7k
3.7k views
LavTheRawkstar asked Sep 11, 2017
3,729 views
What is the ascending wise order of sorting algorithms which takes least time and least space to sort the elements?
0 0 votes
1 answers 1 answer
1.7k
1.7k views
LavTheRawkstar asked Sep 11, 2017
1,719 views
if an array has 1000 elements which sorting to be used ?
0 0 votes
1 1 answer
1.4k
1.4k views
indrajeet asked Feb 24, 2016
1,424 views
Given an unsorted array. The array has this property that every element in array is at most k distance from its position in sorted array where k is a positive integer sma...
0 0 votes
1 answers 1 answer
943
943 views
shikharV asked Jan 19, 2016
943 views
Please explain how heapsort will give us best results?