From e3d571359f6abf641b0a154f0f3905194acf2bca Mon Sep 17 00:00:00 2001 From: Arpan Biswas <99377659+Geeks-Arpan@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:26:41 +0530 Subject: [PATCH] Implement of Bubble Sort Using Golang --- algorithms/go/Bubble Sort | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 algorithms/go/Bubble Sort diff --git a/algorithms/go/Bubble Sort b/algorithms/go/Bubble Sort new file mode 100644 index 0000000..65e9454 --- /dev/null +++ b/algorithms/go/Bubble Sort @@ -0,0 +1,20 @@ +//Bubble sort using Golang + +//TC - O(n^2) + +package main +import "fmt" +func BubbleSort(array[] int)[]int { + for i:=0; i< len(array)-1; i++ { + for j:=0; j < len(array)-i-1; j++ { + if (array[j] > array[j+1]) { + array[j], array[j+1] = array[j+1], array[j] + } + } + } + return array +} +func main() { + array:= []int{11, 14, 3, 8, 18, 17, 43}; + fmt.Println(BubbleSort(array)) +}