• retagged by
983 views

1 Answer

1 1 vote

The question means to ask out of the comparision based sorting algos that we have , what is the lowest possible function corresponding to worst case scenario of number of comparisions..

So this is O(nlogn) as we have worst case for mergesort and heapsort = O(nlogn) which are comparision based algos.

We know that in merge() procedure of mergesort , we require comparision..And we know if we have no of elements in each of the 2 array as n/2 and hence the number of comparision in the worst case is given by = n/2 + n/2  = n

And in mergesort is called recursively 2 times on problem size of n/2..Hence the recurrence relation for no of comparision can be written as :

T(n)  = 2 T(n/2)  + O(n)

==> T(n)  =  O(nlogn)

Hence C) should be the correct answer..

Answer:
Position:
Show:

Related questions

1 1 vote
1 1 answer
1.3k
1.3k views
iarnav asked May 4, 2019
1,258 views
I’ve seen this wikipedia article – https://en.wikipedia.org/wiki/Comparison_sortAlso see this link – https://gateoverflow.in/32948/minimum-number-of-comparisonshttps://ga...
1 1 vote
1 1 answer
10.4k
10.4k views
pradeepchaudhary asked Jul 8, 2018
10,445 views
Q) Consider a situation where swap operation is very costly.Which of the following sorting algorithms should be preferred so that the number of swap operations are minimi...
0 0 votes
1 1 answer
4.6k
4.6k views
Sumit Singh Chauhan asked Aug 18, 2018
4,563 views
What is time complexity of fun()?int fun(int n){ int count = 0; for (int i = n; i 0; i /= 2) for (int j = 0; j < i; j++) count += 1; return count;}(A) O(n^...
0 0 votes
1 answers 1 answer
1.8k
1.8k views
Pankaj Joshi asked Jan 14, 2017
1,763 views
Consider an array consisting of –ve and +ve numbers. What would be the worst time comparisons an algorithm can take in order to segregate the numbers having same sign alt...