retagged by
14,470 views
4 votes
4 votes
What are the number of comparisons in merge sort?

m+n or m+n-1...
retagged by

1 Answer

Best answer
11 votes
11 votes

In best case it  is  min(m, n)  if we consider number of elements in one array is m and in other it is n..

However in worst case it will take m+n-1 comparisons..when alternate element goes into 3rd array which is merged and sorted array..

However number of merges will be same in all cases which is m+n.. 

​​​​​​

selected by

Related questions

6 votes
6 votes
3 answers
1
imamitk9 asked Jun 20, 2017
3,363 views
Q . In the standard merge sort algorithm on a list of size n, what is the maximum number of times an item can be compared?a)2b)lognc)n-1d)NOTMy doubt is here ,Are we cons...
2 votes
2 votes
2 answers
3
sumit goyal 1 asked Aug 9, 2017
725 views
HOW NO. OF LEVELS IS LOG N + 1 CAN ANYONE HELP ME , how to solve this and get log n + 1
0 votes
0 votes
1 answer
4
Santhosh Devulapally asked Jan 3, 2016
6,704 views
IF ONE USES STRAIGHT MERGE SORT TO THE FOLLOWING ELEMENTS 20,47,15,8,9,4,40,30,12,17 THEN THE ORDER OF THE ELEMENTS AFTER 2ND PASS OF THE ALGORITHM