Back to course home
0% completed
Vote For New Content
12. Merge Sort
Problem Statement
Write Recursive Approach for Merge Sort.
The problem is to implement the Merge Sort algorithm using recursion. Merge Sort is an efficient sorting algorithm that follows the divide-and-conquer approach. It divides the input array into two halves, recursively sorts each half, and then merges the sorted halves to obtain the final sorted array.
Examples
# | Input Array | Output | Explanation |
---|---|---|---|
1 | [5, 2, 8, 3, 1, 6] | [1, 2, 3, 5, 6, 8] | The input array is divided into two halves: [5, 2, 8] and [3, 1, 6]. Each half is recursively sorted. Then, the sorted halves are merged to obtain the final sorted array. |
2 | [9, 4, 7, 2, 1] | [1, 2, 4, 7, 9] | The input array is divided into two halves: [9, 4] and [7, 2, 1]. Each half is recursively sorted. Then, the sorted halves are merged to obtain the final sorted array. |
3 | [3, 1, 2, 5, 4] | [1, 2, 3, 4, 5] | The input array is divided into two halves: [3, 1, 2] and [5, 4]. Each half is recursively sorted. Then, the sorted halves are merged to obtain the final sorted array. |
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible