Computer Sciences > GATE 2026 SET-2 > Algorithms
Consider an array 𝐴=[10, 7, 8, 19, 41, 35, 25, 31]. Suppose the merge sort algorithm is executed on array 𝐴 to sort it in increasing order. The merge sort algorithm will carry out a total of 7 merge operations.
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)

Correct : 3

The correct answer is 3.
A void merge occurs when all elements in the left sorted array are less than or equal to all elements in the right sorted array, so the merge simply concatenates L followed by R without interleaving.
Merge sort execution on A = [10, 7, 8, 19, 41, 35, 25, 31]: The algorithm recursively divides until single elements, then merges bottom-up. With 8 elements, there are 7 total merge operations across 3 levels.
Level 1 merges (base case, merging pairs of single elements):
Merge 1: [10] + [7] → [7, 10]. Since 10 > 7, elements interleave. Not void.
Merge 2: [8] + [19] → [8, 19]. Since 8 < 19, output is [8] then [19] directly. Void ✓.
Merge 3: [41] + [35] → [35, 41]. Since 41 > 35, elements interleave. Not void.
Merge 4: [25] + [31] → [25, 31]. Since 25 < 31, output is [25] then [31] directly. Void ✓.
Level 2 merges (merging sorted subarrays of size 2):
Merge 5: [7, 10] + [8, 19] → [7, 8, 10, 19]. Max(L) = 10 > Min(R) = 8, so elements interleave. Not void.
Merge 6: [35, 41] + [25, 31] → [25, 31, 35, 41]. Max(L) = 41 > Min(R) = 25, so elements interleave. Not void.
Level 3 merge (final merge):
Merge 7: [7, 8, 10, 19] + [25, 31, 35, 41] → [7, 8, 10, 19, 25, 31, 35, 41]. Max(L) = 19 < Min(R) = 25, so all of L comes before all of R. Void ✓.
Total void merges = 3.

Similar Questions

Match the following (P) Prim’s algorithm for minimum spanning tree (i) Backtracking (Q) Floyd-Warshall algorithm fo...
#82 MCQ
Consider the following table Algorithms Design Paradigms (P) Kruskal (i) Divide and Conquer...
#203 MCQ
Consider functions Function 1 and Function 2 expressed in pseudocode as follows: Let f1(n) and f2(n) denote the number of times the statement "x = x + 1" is...
#989 MSQ

Related Topics

GATE CS 2026 Set-2 Q32 merge sort void merge GATE 2026 merge sort algorithm GATE CS sorting algorithm merge GATE 2026 algorithms GATE CS 2026 merge operation sorted arrays GATE divide and conquer GATE CS merge sort trace GATE 2026 sorting GATE CS 2026

Unique Visitor Count

Total Unique Visitors

Loading......