From 117867b11442f92f9dc22f9400ca5435fff78d74 Mon Sep 17 00:00:00 2001 From: goliakshay357 <32712438+goliakshay357@users.noreply.github.com> Date: Fri, 11 Oct 2019 10:37:41 +0300 Subject: [PATCH] Swap_count_bs.cpp Counts number of swaps in bs. --- Data Structures/Swap_count_bs.cpp | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Data Structures/Swap_count_bs.cpp diff --git a/Data Structures/Swap_count_bs.cpp b/Data Structures/Swap_count_bs.cpp new file mode 100644 index 0000000..3ccbc4e --- /dev/null +++ b/Data Structures/Swap_count_bs.cpp @@ -0,0 +1,54 @@ +#include +using namespace std; + +int bubble_sort_swap(int array[],int size){ + + int swap =0; + for(int i = size-2;i>=0;i--){ + for(int j=0;j<=i;j++){ + + if(array[j] >array[j+1]){ + + swap++; + // cout<<"Swap:"<