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

binary_search fix #450

Closed
wants to merge 1 commit into from
Closed

binary_search fix #450

wants to merge 1 commit into from

Conversation

pm100
Copy link

@pm100 pm100 commented Apr 6, 2023

simple fix for #449

if we were down to a slice with size == 1 then code tried to access slice[1]

@stale
Copy link

stale bot commented Jun 10, 2023

This issue has been automatically marked as inactive because it has not had recent activity. It will be closed in 15 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Inactive label Jun 10, 2023
@faheel faheel removed the Inactive label Jun 13, 2023
@faheel
Copy link
Member

faheel commented Jun 13, 2023

The following seems like a simpler fix as it prevents the function call for the second time if the value was not found, and also does not require checking the size in each recursive call:

- else if (low <= high)
+ else if (low < high)

@pm100
Copy link
Author

pm100 commented Jun 27, 2023

quite right :-)

@pm100 pm100 closed this Jun 27, 2023
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.

2 participants