From 85ceec7435685ba75434a53ed3f3059075e7d513 Mon Sep 17 00:00:00 2001 From: devacius <81462832+devacius@users.noreply.github.com> Date: Sat, 19 Jun 2021 08:43:04 +0530 Subject: [PATCH] three types of soring has been added . bubble sort insertion sort merge sort has been used and user can do whichever he want by removing the comments from the calling function. --- Algorithms/sorting.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Algorithms/sorting.cpp diff --git a/Algorithms/sorting.cpp b/Algorithms/sorting.cpp new file mode 100644 index 000000000..8c2d86ffc --- /dev/null +++ b/Algorithms/sorting.cpp @@ -0,0 +1,91 @@ +#include +#include +using namespace std; +void bubble_sort(int arr[],int n){ + for(int i =0;iarr[i+1]){ + int temp=arr[i]; + arr[i]=arr[i+1]; + arr[i+1]=temp; + } + + } +} +void insertion_sort(int arr[],int n){ + for(int i=1;i=0 && arr[j]>key){ + arr[j+1]=arr[j]; + j=j-1; + } + arr[j+1]=key; + + } +} +void merge(int arr[],int p ,int q, int r){ + int n1=q-p+1; + int n2=r-q; + int l[n1]; + int b[n2]; + for( int i =0;i>arr[i]; + } +} +void outputarr(int arr[],int n){ + for(int i =0;i>n; + int arr[n]; + std::cout<<"enter the array"; + inputarr(arr,n); + //bubble_sort(arr,n); + // insertion_sort(arr,n); + // merge_sort(arr,0,n-1); + outputarr(arr,n); + + return 0; +} \ No newline at end of file