#C7761. Merge Sort: Efficient Sorting Algorithm
Merge Sort: Efficient Sorting Algorithm
Merge Sort: Efficient Sorting Algorithm
Implement the merge sort algorithm to sort a list (or sequence) of integers in ascending order. Merge sort is a divide-and-conquer algorithm with a recurrence relation given by \(T(n)=2T(\frac{n}{2})+n\). Your task is to take a list of integers from the standard input, sort them using merge sort, and print the sorted list to the standard output.
Task: Write a program that reads a single line of input containing integers separated by spaces. Then, apply the merge sort algorithm to sort these integers and output the sorted list, with the numbers separated by a single space.
Note: Ensure that your program handles edge cases, such as when the input consists of a single number or a list with duplicate or negative numbers.
inputFormat
The input consists of a single line containing zero or more integers separated by spaces. For example:
34 7 23 32 5 62
If there are no integers (i.e. an empty line), consider it as an empty list.
outputFormat
Output a single line with the sorted list of integers in ascending order, separated by a single space. For example:
5 7 23 32 34 62## sample
34 7 23 32 5 62
5 7 23 32 34 62