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 7 merge operations is __________. (answer in integer)
3
Step-by-Step Solution
Key idea: This is a merge sort operation counting question, recognisable because it asks for the number of "void" merge operations on a specific array. A void merge occurs when the left subarray's maximum element is less than or equal to the right subarray's minimum element.
Step 1: Trace the merge sort tree for .
Step 2: Level 3 (size 1 to 2):
- Merge and . Not void ().
- Merge and . Void (). (Count = 1)
- Merge and . Not void ().
- Merge and . Void (). (Count = 2)
Step 3: Level 2 (size 2 to 4):
- Merge and . Not void ().
- Merge and . Not void ().
Step 4: Level 1 (size 4 to 8):
- Merge and . Void (). (Count = 3)
Step 5: Total void merges = 3.
Answer: 3