* add exponential_search algorithm
* replace binary_search with binary_search_recursion
* convert left type to int to be useable in binary_search_recursion
* add docs and tests for exponential_search algorithm
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* move exponential_search to binary_search.py to pass github auto build tests
delete exponential_search.py file
* Update searches/binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* remove additional space searches/binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* return single data type in exponential_search searches/binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* add doctest mod searches/binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* use // instread of int() convert searches/binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* change test according to new code searches/binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* fix binary_search_recursion multiple type return error
* add a timeit benchmark for exponential_search
* sort input of binary search to be equal in performance test with exponential_search
* raise value error instead of sorting input in binary and exonential search to fix bugs
* Update binary_search.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: user <user@kali.user>
* pre-commit: Upgrade psf/black for stable style 2023
Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310
> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…
Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.
I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Chore: Added type hints to searches/binary_search.py
* Use -1 as the sentinal value
* Wrap long lines
* Update binary_search.py
* Update binary_search.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* spelling corrections
* review
* improved documentation, removed redundant variables, added testing
* added type hint
* camel case to snake case
* spelling fix
* review
* python --> Python # it is a brand name, not a snake
* explicit cast to int
* spaces in int list
* "!= None" to "is not None"
* Update comb_sort.py
* various spelling corrections in documentation & several variables naming conventions fix
* + char in file name
* import dependency - bug fix
Co-authored-by: John Law <johnlaw.po@gmail.com>
In binary_search_by_recursion, if you search array for a value that does not exist, you will get this error:
RecursionError: maximum recursion depth exceeded in comparison
To fix this, first check to make sure that the value is between left and right points like this:
if (right < left):
return None
A similar construct has already been applied to binary_search, but did not exist in the recursive alternative.