Open In App

ISRO | ISRO CS 2018 | Question 10

Given two sorted list of size m and n respectively. The number of comparisons needed the worst case by the merge sort algorithm will be

(A) m x n
(B) maximum of m and n
(C) minimum of m and n
(D) m + n – 1

Answer: (D)
Explanation: To merge two lists of size m and n, we need to do m+n-1 comparisons in worst case. Since we need to merge 2 at a time, the optimal strategy would be to take smallest size lists first. The reason for picking smallest two items is to carry minimum items for repetition in merging.

So, option (D) is correct.
Quiz of this Question

Article Tags :