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 Bug Fix and Update for Testing #91

Closed
wants to merge 1 commit into from

Conversation

normand1
Copy link
Contributor

@normand1 normand1 commented Mar 7, 2016

Problem

When searching for a key within a non-complete array (e.g. [0,4,7,9,13,16,34] as opposed to [0,1,2,3,4,5,6,7]) the binarySearch() function returns an initial correct print statement followed by a false positive.

Run:

sorting.binarySearch([0,4,7,9,13,16,34], key: 8)

Result:

   search value 8 not found..
   search value 8 found..

Solution implemented this PR

  • Updated binarySearch(_:) to be testable (now returns true or false depending on whether the key was found in the sequence)
  • Updated the test to test all possible values of a given array

…depending on whether the key was found in the sequence)

- Updated the test to test all possible values within the
@waynewbishop
Copy link
Owner

Hi David, thanks for your interest in the book and for submitting this pull request! So that I can review your work in detail, if you could set the target branch of your PR to point to develop that would be great.

@normand1
Copy link
Contributor Author

normand1 commented Mar 8, 2016

Hi @waynewbishop great book, thanks for writing it. I'll update my PR now.

@normand1 normand1 closed this Mar 8, 2016
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.

None yet

2 participants