Skip to content
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

Comparison issue #135

Closed
gledsoul opened this issue Jun 13, 2024 · 1 comment · Fixed by #141
Closed

Comparison issue #135

gledsoul opened this issue Jun 13, 2024 · 1 comment · Fixed by #141
Labels
enhancement New feature or request help wanted Looking for help from contributors

Comments

@gledsoul
Copy link

gledsoul commented Jun 13, 2024

https://github.com/spring1843/go-dsa/blame/adc15f7574794bfed14bc10c1689415323fa619c/array/bubble_sort.go#L7

the implementation is comparing the elements in a inefficient way

please see the comparison bellow

func bubbleSort(input []int) []int {
    swapped := true
    for swapped {
        swapped = false
        for i := 1; i < len(input); i++ {
            if input[i-1] > input[i] {
                input[i], input[i-1] = input[i-1], input[i]
                swapped = true
            }
        }
    }
    return input
}
@spring1843 spring1843 added the enhancement New feature or request label Jun 26, 2024
@spring1843
Copy link
Owner

@gledsoul thank you for finding this enhancement. Looks like a good change, would you like to open a PR to suggest this improvement?

@spring1843 spring1843 added the help wanted Looking for help from contributors label Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Looking for help from contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants