Skip to content

interval-search provides predicate-based binary and doubling search implementations

License

Notifications You must be signed in to change notification settings

mmore500/interval-search

Repository files navigation

interval-search

Documentation Status

interval-search provides predicate-based binary and doubling search implementations

import interval_search as inch



# inch.binary_search
list_ = [1, 10, 20, 500, 5000]
inch.binary_search(lambda x: list_[x] >= 20, 0, len(list_) - 1)
# -> 2

# inch.doubling_search
inch.doubling_search(lambda x: x >= 5) # -> 5
# with a lower bound to start searching at,
inch.doubling_search(lambda x: x >= 5, 10) # -> 10

# inch.interval_search
# uses binary search or doubling search
# depending on whether upper bound is specified
inch.interval_search(lambda x: list_[x] >= 20, 0, len(list_) - 1)
# -> 2
inch.interval_search(lambda x: x >= 5, 10) # -> 10

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

interval-search provides predicate-based binary and doubling search implementations

Resources

License

Stars

Watchers

Forks

Packages

No packages published