retagged by
361 views

1 Answer

Best answer
4 votes
4 votes

In worst case, number of comparisons to merge two sorted lists of size m and n is m+n-1.

We take two lists of size 8 each, and merge them into a list of size 16. Comparisons needed = 8+8-1 = 15.

Similarly, to merge the other two lists of 8 elements, comparisons needed = 15.

We have two lists of size 16 and 16 now.

To merge them to a list of size 32, number of comparisons needed = 16+16-1 = 31.

Total comparisons = 15 + 15 + 31 = 61.

NOTE: In best case, we need max(m,n) comparisons. It happens when the last element of the first list is smaller than the first element of the second list.

edited by
Answer:

Related questions

1 votes
1 votes
2 answers
1
KISHALAY DAS asked Oct 23, 2016
358 views
What could be the Algo?
6 votes
6 votes
2 answers
2
0 votes
0 votes
1 answer
3
1 votes
1 votes
1 answer
4