From b960572d757de80ed53b4fbb0a0800c5c0efa33a Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Wed, 7 Mar 2018 14:20:30 +0530 Subject: [PATCH 1/8] Create bubble_sort.md --- snippets/bubble_sort.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 snippets/bubble_sort.md diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md new file mode 100644 index 000000000..367d92aba --- /dev/null +++ b/snippets/bubble_sort.md @@ -0,0 +1 @@ +### bubble_sort From f5bbf1f0a38a5c50db7b37817212ab22d93c265b Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Wed, 7 Mar 2018 14:27:50 +0530 Subject: [PATCH 2/8] Update bubble_sort.md --- snippets/bubble_sort.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md index 367d92aba..5b9b3fb30 100644 --- a/snippets/bubble_sort.md +++ b/snippets/bubble_sort.md @@ -1 +1,20 @@ ### bubble_sort + +bubble sort also makes it too simple for sorting any list or array. It simply compares the two neighbouring values and swap them. + +```python +def bubbleSort(arr): + for passnum in range(len(arr)-1,0,-1): + for i in range(passnum): + if arr[i]>arr[i+1]: + temp = arr[i] + arr[i] = arr[i+1] + arr[i+1] = temp + +``` + +```python +arr = [54,26,93,17,77,31,44,55,20] +bubbleSort(arr) +print("sorted %s" arr) # sorted via bubble sort +``` From ef3dc106648003087e2187e32450f1cf43471f11 Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Wed, 7 Mar 2018 14:49:38 +0530 Subject: [PATCH 3/8] Update bubble_sort.md --- snippets/bubble_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md index 5b9b3fb30..dfd10090f 100644 --- a/snippets/bubble_sort.md +++ b/snippets/bubble_sort.md @@ -16,5 +16,5 @@ def bubbleSort(arr): ```python arr = [54,26,93,17,77,31,44,55,20] bubbleSort(arr) -print("sorted %s" arr) # sorted via bubble sort +print("sorted %s" %arr) # sorted via bubble sort ``` From 89678f43571e512adbbc40329f832146403fe487 Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Wed, 7 Mar 2018 14:54:11 +0530 Subject: [PATCH 4/8] Update contributor_database --- contributor_database | 1 + 1 file changed, 1 insertion(+) diff --git a/contributor_database b/contributor_database index d84b059c2..54db09f42 100644 --- a/contributor_database +++ b/contributor_database @@ -23,3 +23,4 @@ is_lower_case:[Rohit Tanwar](@kriadmin) count_by:[Rohit Tanwar](@kriadmin) insertion_sort:[Meet Zaveri](@meetzaveri),[Rohit Tanwar](@kriadmin) difference_by:[Rohit Tanwar](@kriadmin) +bubble_sort: [Shobhit Sachan](@sachans) From 6bd2814825d6aad643b028c9dcbeccef5ee22178 Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Wed, 7 Mar 2018 14:55:07 +0530 Subject: [PATCH 5/8] Update tag_database --- tag_database | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tag_database b/tag_database index b3ba59a8f..1e21a4c20 100644 --- a/tag_database +++ b/tag_database @@ -22,4 +22,5 @@ is_upper_case:string is_lower_case:string count_by:list difference_by:list -insertion_sort:list \ No newline at end of file +insertion_sort:list +bubble_sort: list From 3a7587e1785acaa1e1a5239fe07b04dab21e8d83 Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Thu, 8 Mar 2018 18:21:16 +0530 Subject: [PATCH 6/8] Update bubble_sort.md --- snippets/bubble_sort.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md index dfd10090f..604ee6c0e 100644 --- a/snippets/bubble_sort.md +++ b/snippets/bubble_sort.md @@ -3,7 +3,7 @@ bubble sort also makes it too simple for sorting any list or array. It simply compares the two neighbouring values and swap them. ```python -def bubbleSort(arr): +def bubble_sort(arr): for passnum in range(len(arr)-1,0,-1): for i in range(passnum): if arr[i]>arr[i+1]: @@ -15,6 +15,6 @@ def bubbleSort(arr): ```python arr = [54,26,93,17,77,31,44,55,20] -bubbleSort(arr) -print("sorted %s" %arr) # sorted via bubble sort +bubble_sort(arr) +print("sorted %s" %arr) # [17,20,26,31,44,54,55,77,91] ``` From be621871838ed0e6c6d3bb8c6dcbb14f8b1f9528 Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Fri, 9 Mar 2018 19:21:34 +0530 Subject: [PATCH 7/8] Update bubble_sort.md --- snippets/bubble_sort.md | 1 - 1 file changed, 1 deletion(-) diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md index 604ee6c0e..b5c2797ae 100644 --- a/snippets/bubble_sort.md +++ b/snippets/bubble_sort.md @@ -1,6 +1,5 @@ ### bubble_sort -bubble sort also makes it too simple for sorting any list or array. It simply compares the two neighbouring values and swap them. ```python def bubble_sort(arr): From c0cf66405075e8debcab66a5f8ee837ebd4f86a8 Mon Sep 17 00:00:00 2001 From: Shobhit Sachan <31156049+sachans@users.noreply.github.com> Date: Fri, 9 Mar 2018 19:25:07 +0530 Subject: [PATCH 8/8] Update bubble_sort.md --- snippets/bubble_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md index b5c2797ae..98f7755f0 100644 --- a/snippets/bubble_sort.md +++ b/snippets/bubble_sort.md @@ -1,5 +1,5 @@ ### bubble_sort - +Bubble_sort uses the technique of comparing and swapping ```python def bubble_sort(arr):