retagged by
548 views
1 votes
1 votes

 

retagged by

2 Answers

Best answer
1 votes
1 votes

2-way bottom-up merge sort the last level (except original array) named as level-1, so on... and let n=2k ===> only k levels present totally

if two sorted arrays have n1 and n2 elements ===> to merge them we require no.of comparissions

1) minimum = n1 

2) maximum = n1+n2-1

minimum no.of comparissions required for forming

level 1 :- $\frac{n}{2^{1}} $ . 1

level 2 :- $\frac{n}{2^{2}} $ . 2

level 3 :- $\frac{n}{2^{3}} $ . 4

.

.

.

.

 

level j :- $\frac{n}{2^{j}} $ . 2 j-1

 

Total Comparissions = $\sum_{j=1}^{k} \frac{n}{2^{j}}.2^{j-1}$ = $ \sum_{j=1}^{k} \frac{n}{2} $ = $  \frac{n}{2} \sum_{j=1}^{k} 1 $  = $  \frac{n}{2} (k) $ = $  \frac{n.log(n)}{2} $

selected by
1 votes
1 votes
when all the elements are in increasing order(1,2,3,4,5......n)

lets take example 1, 2, 3, 4, 5, 6, 7, 8  it only requires 12 comparisons.

in 1st level 1+1+1+1 = 4 comparisons

in 2nd level 2+2 = 4 comparisons

in 3rd level 4 comparisons

total 4+4+4 =12 comparisons which is (nlogn/2) C option.

Related questions

4 votes
4 votes
4 answers
1
Aibi asked Oct 8, 2017
2,625 views
Consider bottom-up merge sort working on 'n' elements. Assume 'n' is a power of 2. The minimum number of comparisons in order to get sorted list is(A) (n log n) / 2(B) n ...
1 votes
1 votes
0 answers
3
1 votes
1 votes
1 answer
4
meethunjadhav asked Jul 30, 2018
436 views
suppose merge sort takes 2 sec to sort a set of 64 keys then how much time will take to sort a set of 512 keys?here, ans is 24 sec how it is plz explain me.