What is the order of these elements after second pass of the merge sort…
2021
What is the order of these elements after second pass of the merge sort algorithm? 200, 470, 150, 80, 90, 300, 400, 70, 120
- A.
70, 80, 90, 120, 150, 200, 300, 400, 470
- B.
200, 470, 80, 150, 90, 300, 70, 400, 120
- C.
80, 150, 200, 470, 70, 90, 300, 400, 120
- D.
200, 470, 80, 90, 150, 300, 70, 120, 400
Attempted by 260 students.
Show answer & explanation
Correct answer: C
Bottom-up merge sort treats every element as a sorted run of length 1, then repeatedly merges adjacent runs in pairs, doubling the run length each pass — pass 1 produces runs of size 2, pass 2 merges those into runs of size 4, pass 3 into runs of size 8, and so on. Any run left without a neighbour at the end of a pass simply carries forward unchanged into the next pass.
Start with the array as nine separate runs of size 1: 200 | 470 | 150 | 80 | 90 | 300 | 400 | 70 | 120.
Pass 1 merges adjacent runs in pairs: (200, 470) stays 200, 470; (150, 80) becomes 80, 150; (90, 300) stays 90, 300; (400, 70) becomes 70, 400; the run (120) has no partner and carries forward alone.
After pass 1 the array reads: 200, 470, 80, 150, 90, 300, 70, 400, 120 — four runs of size 2 and one leftover run of size 1.
Pass 2 merges those adjacent runs of size 2 in pairs: merging (200, 470) with (80, 150) gives 80, 150, 200, 470; merging (90, 300) with (70, 400) gives 70, 90, 300, 400; the leftover run (120) still has no partner, so it carries forward unchanged.
After pass 2 the array reads: 80, 150, 200, 470, 70, 90, 300, 400, 120.
Checking the result: all nine original values (200, 470, 150, 80, 90, 300, 400, 70, 120) appear exactly once, and each merged run of four is strictly increasing — 80 < 150 < 200 < 470 and 70 < 90 < 300 < 400 — confirming both merges were carried out correctly.
So the order of the elements after the second pass is: 80, 150, 200, 470, 70, 90, 300, 400, 120.