-
-
Notifications
You must be signed in to change notification settings - Fork 359
Add Go language to bubble sort #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the two nitpicks about fmt.Println it seems good
|
||
func main() { | ||
array := [10]int{1, 45, 756, 4569, 56, 3, 8, 5, -10, -4} | ||
fmt.Println("Unsorted array:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just fmt.Println("Unsorted array: ", array)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to this format in both the cases, thanks!
|
||
bubbleSort(array[:]) | ||
|
||
fmt.Println("Sorted array:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, why not just: fmt.Println("Sorted array: ", array)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, its simpler this way, I changed it. Initially it was like that because I wanted it to be like the output format of the C bubble sort.
Adds a Go implementation for bubble sort. If you have Go installed, you can do
go run bubbleSort.go
Edit: Also I'm not sure whether I'm supposed to add myself to the Contributors list yet, so I haven't.