 October 13, 2023
October 13, 2023
October 13, 2023
###### Algorithms
October 13, 2023
 Question 37

Suppose P, Q, R, S, T are sorted sequences having lengths 20, 24, 30, 35, 50 respectively. They are to be merged into a single sequence by merging together two sequences at a time.  The number of comparisons that will be needed in the worst case by the optimal algorithm for doing this is ______.

 A 358 B 359 C 360 D 361
Question 37 Explanation:
The implementation of optimal algorithm for merging sequences is as follows. In the above implementation, total number of comparisons is
(44-1) + (94-1) + (65-1) + (159-1) = 358
Hint: The number of comparisons for merging two sorted sequences of length m and n is m+n-1.
Question 37 Explanation:
The implementation of optimal algorithm for merging sequences is as follows. In the above implementation, total number of comparisons is
(44-1) + (94-1) + (65-1) + (159-1) = 358
Hint: The number of comparisons for merging two sorted sequences of length m and n is m+n-1.