Skip to content

Algorithm yields incorrect results #5

Description

@maja42

The following input data:

arr := []int{65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39}
pivot := 8
_ = quickselect.IntQuickSelect(arr, pivot)

reorders the data to the following:

[28 33 21 22 50 12 28 39 *59* 56 90 53 65 77 95]

As you can see, the value at index 8 (59) is higher than the 56 at index 9.

A correct example would be:

[21 12 22 33 28 28 39 50 53 56 59 65 90 77 95]

(as produces by https://github.com/keegancsmith/nth)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions