Answer the question
In order to leave comments, you need to log in
Merge sort with bounds output. How to implement?
You want to sort an array in non-descending order using merge sort.
To make sure that merge sort is actually used, after each merge performed (that is, when the corresponding subarray is already sorted!), it is required to print the indexes of the boundary elements and their values.
Input format
The first line contains one natural number N, not exceeding 105 - the size of the array. The second line contains N numbers - array elements.
Output format Output
the resulting array in the last line of the output file.
All preceding lines describe the merges that were made, one on each line. Each such line must contain four numbers: the index of the start of the merge area, the index of the end of the merge area, the value of the first element of the merge area, the value of the last element of the merge area. Indexes should be numbered starting from one.
input
1
1
output
1
input
2
3 1
output
1 2 1 3
1 3
input
5
5 4 3 2 1
output
1 2 4 5
4 5 1 2
3 5 1 3
1 5 1 5
1 2 3 4 5
please tell the oiler the solution on C#
THANKS IN ADVANCE.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question