Merge Sort Task
Given a sequence of numbers, denoted as ARR
, your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Example:
Explanation:
The Merge Sort algorithm is based on Divide and Conquer. It splits the input array into two parts, continuing until each part has a size of '1'. It then merges the sorted arrays to return one fully sorted array.
The above illustration shows how merge sort works.
Input:
The first line of input contains an integerT
denoting the number of test cases.
The next2*T
lines represent theT
test cases.
The first line of each test case contains an integerN
which denotes the size ofARR
.
The second line of each test case containsN
space-separated elements ofARR
.
Output:
For each test case, output the numbers in non-descending order.
Constraints:
1 ≤ T ≤ 50
1 ≤ N ≤ 10^4
-10^9 ≤ arr[i] ≤ 10^9
- Time Limit: 1 sec
Note:
It is compulsory to use the 'Merge Sort' algorithm.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
Be the first one to answer
Add answer anonymously...
Top Comviva Technology Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Comviva Technology Software Developer
>
Comviva Technology Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app