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.
subsequence
The above illustration shows how merge sort works.

Input:

The first line of input contains an integer T denoting the number of test cases.
The next 2*T lines represent the T test cases.
The first line of each test case contains an integer N which denotes the size of ARR.
The second line of each test case contains N space-separated elements of ARR.

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!
Select
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
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits