1,084 views

3 Answers

2 2 votes
if you have extra space you can go for merge sort. else you should have to remain happy with the heap sort . intuitively if you see, if an array is sorted  we are  to swap/assign a lot in merge sort but that's not the case in heap sort.you call heapify(A,i) you are not going to swap once also .

 

so better go for heap sort.....
1 1 vote
MergerSort is better because for larger datasets, mergesort works faster and is stable. Also it can be parallelized. As for Heapsort , sorting is not stable also there is a overhead of maintaining heap.
0 0 votes

Merge sort is better

Reason- it always have same complexity irrespective of input , so easier to analyse. While that is not the case in heap sort.

Position:
Show:

Related questions

1 1 vote
1 1 answer
756
756 views
Rajesh Pradhan asked Feb 22, 2016
756 views
What is digital signature? How does it work?
1 1 vote
1 1 answer
1.3k
1.3k views
Rajesh Pradhan asked Feb 22, 2016
1,279 views
Have you heard of ethernet?” I said “Yes!”. Then I was asked “Can we lay an ethernet LAN between Delhi and Bangalore?
1 1 vote
1 answers 1 answer
623
623 views
Rajesh Pradhan asked Feb 22, 2016
623 views
Which is greater root(n) or 2^root(logn)
0 0 votes
0 0 answers
258
258 views
Sarwari_Mallela asked Feb 18
258 views
Hello,I have just written the GATE 2026 (Computer Science) exam, and I’m feeling a bit lost about how to prepare next—especially for interviews and further selection proc...