ISRO Scientist/Engineer CSE 2018Algorithms › Sorting
ISRO Scientist/Engineer CSE 2018 PYQ: Given two sorted list of size $m$ and $n$ respectively. The number of comparisons needed the worst case by…
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 \times n$
- Bmaximum of $m$ and $n$
- Cminimum of $m$ and $n$
- D$m+n-1$Correct answer
Answer
(D) $m+n-1$
Approach
The question asks for the worst-case number of comparisons performed by the merge step of merge sort when combining two already-sorted lists of sizes $m$ and $n$. The key insight is that each comparison places exactly one element into the output, and the process stops comparing once one list is exhausted.
Reviewed by ISRO IQ Editorial Team.