1 1 vote Algorithms greedy-algorithms + – NIL DAS 413 views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply NIL DAS commented Dec 10, 2025 reply Follow flag The answer given is O(n^2) but how? 0 0 replyShare Amjad. commented Dec 10, 2025 reply Follow flag @NIL DASassume 5,4,3,2,1 is the array!at each level the varition of merge sort is dividing it like this :$L_o \ :$ {5,4,3,2,1}$L_1 \ :$ {5}{4,3,2,1}$L_2 \ :$ {5}{4}{3,2,1}$L_3 \ :$ {5}{4}{3}{2,1}$L_4 \ :$ {5}{4}{3}{2}{1}number of level that are created are 5 and now at each level will sort element that is 5 elements ( i.e compare and swap) , so the total cost of operations will take 5 * 5 = 25 total operations to sort This question is similar to having the maximum or minimum element as the pivot in the Quick sort Algorithm.hope this helps! 0 0 replyShare Please log in or register to add a comment.
2 2 votes answer will be O(n^2) see, for normal merge sort, we do T(n)=2T(n/2) + n, here n because comparing and mergin takes order of n time now in this question, it will be T(N)=T(1) + T(n-1) + n this will give us order of n^2 mrityunjay59 answered Dec 16, 2025 mrityunjay59 comment Share Follow See 1 comment 1 1 comment reply NIL DAS commented Dec 19, 2025 reply Follow flag thanks 0 0 replyShare Please log in or register to add a comment.