From e9a7e93be9cf7f2aba018cdacb340459a6402a73 Mon Sep 17 00:00:00 2001 From: Supratick2001 <72028007+Supratick2001@users.noreply.github.com> Date: Mon, 4 Oct 2021 14:33:40 +0530 Subject: [PATCH] Create Merge sort in cpp merge sort code added --- Merge sort in cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Merge sort in cpp diff --git a/Merge sort in cpp b/Merge sort in cpp new file mode 100644 index 0000000..b806565 --- /dev/null +++ b/Merge sort in cpp @@ -0,0 +1,69 @@ +#include +using namespace std; +void swapping(int &a, int &b) { //swap the content of a and b + int temp; + temp = a; + a = b; + b = temp; +} +void display(int *array, int size) { + for(int i = 0; i> n; + int arr[n]; //create an array with given number of elements + cout << "Enter elements:" << endl; + for(int i = 0; i> arr[i]; + } + cout << "Array before Sorting: "; + display(arr, n); + mergeSort(arr, 0, n-1); //(n-1) for last index + cout << "Array after Sorting: "; + display(arr, n); +}