A merge operation on sorted left array and sorted right array is said to be void if the output of the merge operation is the elements of array followed by the elements of array .
The number of void merge operations among these merge operations is . (answer in integer)
View worked solution
Answer: 3:3
A merge operation on sorted arrays and is void if the merged output is exactly concatenated with . Since and are already sorted, this condition holds if and only if:
Let us trace the standard merge sort execution on the array by recursively splitting it into halves:
- Merge 1: ,
→ Not Void - Merge 2: ,
→ Void - Merge 3: ,
→ Not Void - Merge 4: ,
→ Not Void - Merge 5: ,
→ Void - Merge 6: ,
→ Not Void - Merge 7: ,
→ Void
Thus, there are exactly 3 void merge operations (Merge 2, Merge 5, and Merge 7).
Free practice · Your answers on this page are not saved.
