Code
#include <stdio.h> #include <stdlib.h> // Function to merge two subarrays of arr[] void merge(int arr[], int left, int middle, int right) { int i, j, k; int n1 = middle - left + 1; int n2 = right - middle; // Create temporary arrays int L[n1], R[n2]; // Copy data to temporary arrays L[] and R[] for (i = 0; i < n1; i++) L[i] = arr[left + i]; for (j = 0; j < n2; j++) R[j] = arr[middle + 1 + j]; // Merge the temporary arrays back into arr[l..r] i = 0; // Initial index of first subarray j = 0; // Initial index of second subarray k = left; // Initial index of merged subarray while (i < n1 && j < n2) { if (L[i] <= R[j]) { arr[k] = L[i]; ...