geeksforgeeks-マージソート
Geeksforgeeks Merge Sort
アルゴリズムの説明: http://www.geeksforgeeks.org/merge-sort/
テストの質問
マージソート(機能の問題)
タスクは、マージソートを実装するために使用されるmerge()関数を完了することです。
入力:
入力の最初の行は、テストケースの数「T」を示します。テストケースの最初の行は配列のサイズで、2番目の行は配列要素で構成されています。
出力:
昇順でソートされた配列がユーザーに表示されます。
制約:
1<=T<= 50
1<=N<= 1000
1<=arr[i]<= 1000
例:
入力:
二
5
4 1 3 9 7
10
10 9 8 7 6 5 4 3 2 1
出力:
1 3 4 7 9
1 2 3 4 5 6 7 8 9 10
C ++
/* Please note that it's Function problem i.e. you need to write your solution in the form of Function(s) only. Driver Code to call/invoke your function would be added by GfG's Online Judge.*/ /* The task is to complete merge() which is used in below mergeSort() */ /* l is for left index and r is right index of the sub-array of arr to be sorted void mergeSort(int arr[], int l, int r) { if (l