Skip to content

[BUG]: small bug in comb sort #1443

@anonymouss

Description

@anonymouss

for (int i = l; i <= r - gap; ++i) {

should be i < r - gap, otherwise, when i = r - gap, arr[i + gap] will be index out of bound.

btw, swapped flag seems to be redundant here in while (gap != 1 || swapped) {}, no matter swapped is true or false, loop ends when gap == 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions