-
Notifications
You must be signed in to change notification settings - Fork 302
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.c Add Binary Search Algorithm #490
Conversation
This add Binary Search Algorithm which return the index of the searched item. Closes #53
binary_search/C/binary_search.c
Outdated
int n = 10; | ||
int x = 13; | ||
int result = binarySearch(arr, 0, n - 1, x); | ||
printf("Index of %d in array is: %d\n", x, result); |
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.
Line contains following spacing inconsistencies:
- Spaces used instead of tabs.
Origin: SpaceConsistencyBear, Section: all.cpp
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmp5svrmu9u/binary_search/C/binary_search.c
+++ b/tmp/tmp5svrmu9u/binary_search/C/binary_search.c
@@ -22,6 +22,6 @@
int n = 10;
int x = 13;
int result = binarySearch(arr, 0, n - 1, x);
- printf("Index of %d in array is: %d\n", x, result);
+ printf("Index of %d in array is: %d\n", x, result);
return 0;
}
binary_search/C/binary_search.c
Outdated
#include <stdio.h> | ||
|
||
int binarySearch(int arr[], int start, int end, int item) | ||
{ |
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.
{ should almost always be at the end of the previous line [whitespace/braces] [4]
Origin: CPPLintBear, Section: all.cpplint
.
binary_search/C/binary_search.c
Outdated
} | ||
|
||
int main() | ||
{ |
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.
{ should almost always be at the end of the previous line [whitespace/braces] [4]
Origin: CPPLintBear, Section: all.cpplint
.
Comment on 243b68e, file binary_search/C/binary_search.c, line 4. { should almost always be at the end of the previous line [whitespace/braces] [4] Origin: CPPLintBear, Section: |
Comment on 243b68e, file binary_search/C/binary_search.c, line 20. { should almost always be at the end of the previous line [whitespace/braces] [4] Origin: CPPLintBear, Section: |
This add Binary Search Algorithm which return the index of the searched item.
Closes #53
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Fixes #{ISSUE_NUMBER}
By submitting this pull request I confirm I've read and complied with the
below declarations.
{Tag}: Add {Algorithm/DS name} [{Language}]
, notUpdate README.md
orAdded new code
.After you submit your pull request, DO NOT click the 'Update Branch' button.