1,976 views

4 Answers

2 2 votes
we have 4 sorted list each of 8 element(keys)
1 list .
2 list
3 list
4 list
now  to merge  first  two list i.e.

 list 1 list 2 we need (m+n-1) comparison  =15..........................LIST A(16 element)

 list 3 list 4 we need (m+n-1) comparison  =15........................... LIST B(16 element)
 now to merge these two we require   (16+16-1)=31
total 15+15+31=61
0 0 votes
isanswer 61?
0 0 votes

Number of comparisons requires : $nlogn-2^{^logn}+1$ (Formula)

so , substituting values in formal:

8*3-8+1=17.

since there are 4 lists : 4*17= 68.

And now it is mentioned in question that list is sorted so all (n-1) elements are sorted so we have to remove it from counting comparisons: 68-7= 61.

http://stackoverflow.com/questions/12346054/number-of-comparisons-in-merge-sort

0 0 votes
Using the merge algorithm.. If one sorted list has m elements and another has n elements then it requires m+n-1 comparisons during merging of list in worst case...

There are four list of 8 elements.. First two list requires 8+8-1=15 comparison and another two list requires 8+8-1=15 comparison.. Now we have two list of 16 elements, the number of comparison required is 16+16-1=31 comparison..

Total we have 15*2+31=61 comparison
Position:
Show:

Related questions

0 0 votes
0 0 answers
1.0k
1.0k views
srestha asked Aug 18, 2018
1,032 views
why this margeSort program showing time limit exceed ?#include <stdio.h #include <stdlib.h #include <time.h void fillArray(int array[], int n) { time_t t; time(&t);//get ...
1 1 vote
1 1 answer
152
152 views
GO Classes asked Aug 10
152 views
Mergesort recursively sorts the two halves of an array.After both recursive calls have finished, but before the merge operation, which statement must be true?The complete...
1 1 vote
4 4 answers
5.7k
5.7k views
iarnav asked Apr 25, 2019
5,657 views
In Merge sort Algorithm when I took input array of size 2 and I got 4 function calls as including original function call with which I call MS algorithm i.e. MS (1,2) and ...
0 0 votes
0 0 answers
999
999 views
Nandkishor3939 asked Jan 21, 2019
999 views
What is the extra memory needed for merge sort:1] In case of Iterative merge sort.(DS:Array)2]In case of Recursive merge sort.(DS:Array)3] In case of Iterative merge sort...