in Algorithms retagged by
634 views
0 votes
0 votes

no of comparisons in merge sort max?

how many max no swaps??[if inplace algo]

in Algorithms retagged by
634 views

2 Comments

Number of comparison will be nlogn for merge sort.

There are logn levels each level has comparisons equal to n.
0
0

1 Answer

0 votes
0 votes

in the worst case n^2 swaps.

max. swap occur when array will be like this [(3,4),(1,2)] or [(5,6,7,8)(1,2,3,4)].

https://www.geeksforgeeks.org/in-place-merge-sort/ (use this algo to calculate no. of swaps).

Correct me if i'm wrong?

Related questions

0 votes
0 votes
0 answers
3