2,681 views

3 Answers

Best answer
6 votes
6 votes

Quick sort performs very gud if the elements are randomly generated.  even if Quick Sort and Merge Sort have same complexity on average and in best case scenario, the constants (hidden by the big-O notation) are much smaller in Quick Sort leading to a smaller running time on average.  looking at the table we can easy know that the comparision is between mege and quick . heap is not so efficient to be compared,(http://ddeville.me/2010/10/sorting-algorithms-comparison/)

selected by
1 votes
1 votes
I feel heap sort is preferable as at any moment if we wish to add any randomly generated element to the list then the list needs to be sorted after it to get the element in sorted order. so we can just add the element and call maxheapify or minheapify as our requirement  and get it sorted for the randomly added element

I feel if our list is static i.e data need not be added later then we can go ahead with sorting as the sorted order wont be affected later

but if we want to make any changes either add or delete any element then i feel heap is the best as it does minimal work for moving element and even maintaining the property
0 votes
0 votes

I think we can go for heap sort in this case as its complexity is nlogn for both worst and best case scenario.

Given that numbers are randomly generated quick sort may achieve its worst case of n^2  i.e. when most of the numbers are already sorted.

But on other side heap sort is not going to be hampered by already sorted numbers and going to give nlogn each time which is also the best case complexity of quick sort.

 

Related questions

0 votes
0 votes
1 answer
1
sh!va asked Jul 1, 2016
8,221 views
You are asked to sort 15 randomly generated numbers. You should preferA.bubble sortB.Selection sortC.Insertion sortD.Quick sortAns is given as Bubble sort. How it is sele...
0 votes
0 votes
3 answers
2
radha gogia asked Jul 17, 2015
980 views
If we talk about that since since we cant access any random element in a linked list for that reason quick sort cant be used for linked lists ,then in merge sort also we ...
4 votes
4 votes
2 answers
3
worst_engineer asked Oct 7, 2015
6,077 views
In quick sort , for sorting n elements , the (n/4)th smallest element is selected as pivot using an O(n) time algorithm. What will be the time complexity?it is $\Theta (...
1 votes
1 votes
1 answer
4
iarnav asked May 4, 2019
852 views
I’ve seen this wikipedia article – https://en.wikipedia.org/wiki/Comparison_sortAlso see this link – https://gateoverflow.in/32948/minimum-number-of-comparisonshttp...