Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure to add correct end boundary for input #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mabrod
Copy link

@mabrod mabrod commented Feb 17, 2023

binary search recursive implementation does not handle correctly scenario when an element to search for is greater than the last input element by throwing the following exception:
java.lang.ArrayIndexOutOfBoundsException: 10
at com.packt.datastructuresandalg.lesson2.sorting.BinarySearchRecursive.binarySearch(BinarySearchRecursive.java:12)

to fix it you need to make sure that in recursive binary search helper method you pass index of last element by subtracting 1 from the length of the input, not the length of the input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant