retagged by
1,721 views
0 0 votes
Suppose there are k sorted lists (decreasing order) with n/k elements in each list.

What is the time complexity to merge them into one single sorted list.

Hint: Maintain a heap of k elements. Think which k elements to choose.

 

A. O(nlogk)

B. O(n)

C. O(nk)

D. O(nlogn)

3 Answers

4 4 votes

Option A should be TRUE

i don’t know why it is unchecked for correction for almost an year

0 0 votes

D. O(nlogn)...

 

Hence the total time for merge Sort function will become n(log n + 1) , which gives us a time complexity of O(n*log n) …

Time complexity of Merge Sort is O(n*Log n) in all the 3 cases (worst, average and best) as merge sort always divides the array in two halves and takes linear time to merge two halves...

 

1. https://gateoverflow.in/16103/The-time-complexity-of-producing-a-sorted-list

 

 

0 0 votes
T(n) = O(nlogk)

option A
Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
1.1k
1.1k views
rsansiya111 asked Dec 8, 2021
1,083 views
Consider the following algorithm on a graph with edge weights.Sort the edges as [e1,e2,...,em] in decreasing order of cost.Start with the original graph. Consider each ed...
1 1 vote
1 answers 1 answer
659
659 views
rsansiya111 asked Dec 7, 2021
659 views
In an array A[1..n] of n distinct elements, if i < j and A[i] A[j], then the pair (i,j) is called an inversion of A.How many inversions are there in the array A = {n,n-1...
0 0 votes
1 1 answer
2.2k
2.2k views
rsansiya111 asked Dec 8, 2021
2,152 views
Suppose we want to extend the union-find data structure to support the operation Reset(c), which takes as input the name of a component c and then breaks up c into single...
2 2 votes
1 answers 1 answer
1.3k
1.3k views
rsansiya111 asked Dec 8, 2021
1,338 views
Suppose we do merge sort with a three-way split: divide the array into 3 equal parts, sort each part and do a 3 way merge.What would the worst-case complexity of this ver...