Skip to content

[BUG] InterpolationSearch().find(...) breaks on certain sorted arrays #7466

@Grover-c13

Description

@Grover-c13

Description

Certain sorted array inputs cause a division by 0 exception.

this was found while writing a test proof

Steps to reproduce

Run the find with the following examples:

  • [0, 0, 0, 2], 2
  • [2, 2, 2, 2], 2
  • [0, 1, 2, 4], 4

you will get a division by 0 exception

Expected behavior

No division by 0 exception.

For the above examples the following outputs:

  • [0, 0, 0, 2], 2 -> 3
  • [2, 2, 2, 2], 2 -> 0
  • [0, 1, 2, 4], 4 -> 3

Screenshots

No response

Additional context

Fix tested here with the same proof: bmc4j/bmc4j-proofs-the-algorithms-java#4

Happy to make PR - making this issue as instructed in the contributors guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions