8 3 1 4 1 5 9 2 6
For this input, the required output is 1 1 2 3 4 5 6 9.
1 1 2 3 4 5 6 9
5 5 4 3 2 1
For this input, the required output is 1 2 3 4 5.
1 2 3 4 5
4 7 7 7 7
For this input, the required output is 7 7 7 7.
7 7 7 7
Given an array of nnn integers, sort them in non-decreasing order.
Implement the Merge Sort algorithm, which divides the array into halves, recursively sorts each half, and merges them back together.
a1a2⋯an (sorted)a_1 \quad a_2 \quad \cdots \quad a_n \text{ (sorted)}a1a2⋯an (sorted)