From 41a027117a83edc3fc91f6ad6ca6fd40c047472a Mon Sep 17 00:00:00 2001 From: FaizAlam Date: Thu, 8 Oct 2020 19:58:43 +0530 Subject: [PATCH 1/4] Added BubbleSort Algorithm using python --- BubbleSortPython.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 BubbleSortPython.py diff --git a/BubbleSortPython.py b/BubbleSortPython.py new file mode 100644 index 0000000..1651b69 --- /dev/null +++ b/BubbleSortPython.py @@ -0,0 +1,20 @@ +#python program for bubble sort +def bubbleSort(list): + l =len(list) + + for i in range(l-1): + for j in range(0,l-i-1): + + # Swap if the element found is greater than the next element + + if list[j] > list[j+1]: + list[j], list[j+1] = list[j+1], list[j] + + +list=[10,14,9,5,2,18,7] + +bubbleSort(list) +#sorted array = 2,5,7,9,10,14,18 +print("Sorted array is: ") +for i in range(len(list)): + print(list[i]) \ No newline at end of file From ca203566d582766c104b712b7885fe7a2f7c6cbc Mon Sep 17 00:00:00 2001 From: FaizAlam Date: Thu, 8 Oct 2020 22:08:46 +0530 Subject: [PATCH 2/4] Added BubbleSort implementation using C++ --- Bubble_Sort/BubbleSort_Cpp.c++ | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Bubble_Sort/BubbleSort_Cpp.c++ diff --git a/Bubble_Sort/BubbleSort_Cpp.c++ b/Bubble_Sort/BubbleSort_Cpp.c++ new file mode 100644 index 0000000..1301307 --- /dev/null +++ b/Bubble_Sort/BubbleSort_Cpp.c++ @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long ll; +void swap(int *x,int *y){ + int temp=*x; + *x=*y; + *y=temp; +} +void BubbleSort(int list[],int n){ + int i,j; + for(i=0;ilist[j+1]) + swap(&list[j],&list[j+1]); +} +int main(){ + int list[]={64,34,25,12,22,11,90}; + int i,n=sizeof(list)/sizeof(list[0]); + BubbleSort(list,n); + cout<<"Sorted listay: \n"; + for(i=0;i Date: Thu, 8 Oct 2020 22:16:36 +0530 Subject: [PATCH 3/4] Added BubbleSort implementation using C++ --- Bubble_Sort/BubbleSort_Cpp.c++ | 1 + 1 file changed, 1 insertion(+) diff --git a/Bubble_Sort/BubbleSort_Cpp.c++ b/Bubble_Sort/BubbleSort_Cpp.c++ index 1301307..a00768f 100644 --- a/Bubble_Sort/BubbleSort_Cpp.c++ +++ b/Bubble_Sort/BubbleSort_Cpp.c++ @@ -32,3 +32,4 @@ int main(){ cout << endl; return 0; } +gity \ No newline at end of file From ceb0008873e6c83a72d4816cc50021e392da5f1d Mon Sep 17 00:00:00 2001 From: FaizAlam Date: Thu, 8 Oct 2020 22:49:30 +0530 Subject: [PATCH 4/4] Added BubbleSort implementation using c++ --- Bubble_Sort/BubbleSort_Cpp.c++ | 1 - 1 file changed, 1 deletion(-) diff --git a/Bubble_Sort/BubbleSort_Cpp.c++ b/Bubble_Sort/BubbleSort_Cpp.c++ index a00768f..1301307 100644 --- a/Bubble_Sort/BubbleSort_Cpp.c++ +++ b/Bubble_Sort/BubbleSort_Cpp.c++ @@ -32,4 +32,3 @@ int main(){ cout << endl; return 0; } -gity \ No newline at end of file