DSA Lab Manual(Merge Sort )
DSA Lab Manual(Merge Sort )
// Main function
int main() {
int arr[] = {38, 27, 43, 3, 9, 82, 10};
int arr_size = sizeof(arr) / sizeof(arr[0]);
Output
Example Input:
Given array is:
38 27 43 3 9 82 10
Example Output:
Sorted array is:
3 9 10 27 38 43 82
Practice Questions
1. Analyze the time complexity of the Merge Sort algorithm for arrays of size 4, 8, and 16.
2. Modify the code to sort an array of floating-point numbers.
3. Implement Merge Sort iteratively instead of recursively.
Conclusion
Merge Sort is an efficient, stable, and widely used sorting algorithm with a consistent time
complexity of O(n log n). It is especially useful for large datasets where stability and predictable
performance are critical.