Merge Sort is a recursive sorting algorithm based on the divide-and-conquer approach. The array is divided into two halves, and these halves are recursively sorted. The mergeSort() function splits the array, and the merge() function combines two sorted subarrays back into one. It operates in O(n log n) time complexity, making it efficient for large datasets. This code takes input for the size and elements of the array from the user, sorts the array using merge sort, and then prints the sorted array. The merge process ensures the subarrays are combined in sorted order.
Merge Sort is a recursive sorting algorithm based on the divide-and-conquer approach. The array is divided into two halves, and these halves are recursively sorted. The mergeSort() function splits the array, and the merge() function combines two sorted subarrays back into one. It operates in O(n log n) time complexity, making it efficient for large datasets. This code takes input for the size and elements of the array from the user, sorts the array using merge sort, and then prints the sorted array. The merge process ensures the subarrays are combined in sorted order.