From 8c7eb3220c0c08ee95ff347f296c7057647aa1ac Mon Sep 17 00:00:00 2001 From: Srutip04 Date: Sun, 11 Apr 2021 21:05:44 +0530 Subject: [PATCH] insertion sort added --- cpp/algorithms/insertionsort.cpp | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cpp/algorithms/insertionsort.cpp diff --git a/cpp/algorithms/insertionsort.cpp b/cpp/algorithms/insertionsort.cpp new file mode 100644 index 000000000..f07ceca71 --- /dev/null +++ b/cpp/algorithms/insertionsort.cpp @@ -0,0 +1,33 @@ +//INSERT SORT ALGORITHM IN C++ +#include +using namespace std; +int main() +{ + int n;cin>>n; + int a[n]; + + for(int i=0;i>a[i]; + + } + for(int i=1;icurrent && j>=0) + { + a[j+1]=a[j]; + j--; + } + a[j+1]=current; + } + + + + + for(int i=0;i