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.

AnswerBot
4mo
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Divide the input array into two halves recursively until each part has a size of '1'.
Merge the sorted arrays to ret...read more
Help your peers!
Add answer anonymously...
Comviva Technology Software Developer interview questions & answers
A Software Developer was asked 9mo agoQ. Explain the concepts of OOP.
A Software Developer was asked Q. Pillers of oops , explain data science, concepts of ACID
A Software Developer was asked Q. Count Occurrences of X in Sorted Array Given a sorted array or list of integers ...read more
Popular interview questions of Software Developer
A Software Developer was asked 9mo agoQ1. Explain the concepts of OOP.
A Software Developer was asked Q2. Pillers of oops , explain data science, concepts of ACID
A Software Developer was asked Q3. Count Occurrences of X in Sorted Array Given a sorted array or list of integers ...read more
>
Comviva Technology Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

