-
Notifications
You must be signed in to change notification settings - Fork 43
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
sockets-Bita #28
base: master
Are you sure you want to change the base?
sockets-Bita #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a good idea here, but a few bugs in your binary search. Take a look at my inline comments and let me know if you have questions.
return true | ||
elsif array[mid] < value_to_find | ||
i = mid + 1 | ||
j = array.length - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are ending up reseting the top value of your search criteria here! This line shouldn't be here!
end | ||
return intersection | ||
else | ||
array = array2.sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this else you're not setting i to zero.
mid = array.length / 2 | ||
i = 0 | ||
j = array.length - 1 | ||
while i < j |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really what you want for the while loop here? What if the array is 1 element in size?
No description provided.