diff --git a/insertionSort.cpp b/insertionSort.cpp new file mode 100644 index 0000000..506fd45 --- /dev/null +++ b/insertionSort.cpp @@ -0,0 +1,32 @@ +#include +using namespace std; + +void insertion(int n, int a[]){ + int key,j; + for(int i=1;i=0 && a[j]>key){ + a[j+1] = a[j]; + j--; + } + a[j+1]=key; + } +} + +int main(){ + int n; + cout<<"Enter the size of the array : "; + cin>>n; + int a[n]; + cout<<"Enter the array elements\n"; + for(int i=0;i>a[i]; + } + insertion(n,a); + cout<<"The sorted array is : "; + for(int j=0;j