Skip to content

Comparison issue  #135

Closed
Closed
@gledsoul

Description

@gledsoul

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedLooking for help from contributors

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions