1-3
1-3
Aim: To implement the Merge Sort algorithm in C and analyze its time complexity.
Objective:
To understand and implement the Divide and Conquer approach.
To analyze the time complexity of Merge Sort.
To sort an array using the Merge Sort technique.
Time Complexity:
Best Case: O(n log n)
Average Case: O(n log n)
Worst Case: O(n log n)
Program:
#include <stdio.h>
i++;
swap(&arr[i], &arr[j]);
}
}
swap(&arr[i + 1], &arr[high]);
return (i + 1);
}
void quickSort(int arr[], int low, int high) {
if (low < high) {
int main() {
int arr[] = {10, 7, 8, 9, 1, 5};
int size = sizeof(arr) / sizeof(arr[0]);
int main() {
int arr[] = {7, 10, 4, 3, 20, 15};
int size = sizeof(arr) / sizeof(arr[0]);
int k = 3;
ig }
3-th smallest element is 7
PS C:\Users\user\OneDrive\Desktop\JS DOM>