Merge Sort Problem Statement

You are given a sequence of numbers, ARR. Your task is to return a sorted sequence of ARR in non-descending order using the Merge Sort algorithm.

Explanation:

The Merge Sort algorithm is a Divide and Conquer approach. It recursively divides the input array into two halves until the size of each array is 1, then merges the sorted halves to produce a completely sorted array.

Input:
The first line of the input contains an integer ‘T’ representing the number of test cases.
The following 2 * T lines provide the test cases.
For each test case:
- The first line contains an integer ‘N’, representing the number of elements in ‘ARR’.
- The second line contains ‘N’ space-separated integers representing the elements of ‘ARR’.
Output:
For each test case, return the numbers sorted in non-descending order.

Example:

Input:
T = 1
N = 5
ARR = [3, 1, 4, 1, 5]
Output:
[1, 1, 3, 4, 5]

Constraints:

  • 1 <= T <= 50
  • 1 <= N <= 10^4
  • -10^9 <= arr[i] <= 10^9
  • Time Limit: 1 second
Note:
You are not required to print the output; just implement the function as specified by the problem statement.
AnswerBot
1y

The task is to implement the merge sort algorithm to sort a given sequence of numbers in non-descending order.

  • Merge sort is a divide and conquer algorithm that recursively divides the input array into...read more

Help your peers!
Select
Add answer anonymously...

Top Software Developer Intern Interview Questions Asked at ShareChat

Q. Flood Fill Algorithm Task Assist Ninja in altering the color of a specific regio...read more
Q. Saving Money Problem Statement Ninja is adventurous and loves traveling while be...read more
Q. Flip Bit to Win Problem Statement You are given a task to help ninjas maximize t...read more
Software Developer Intern 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