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.c Add Binary Search Algorithm #490

Closed
wants to merge 3 commits into from
Closed

binary_search.c Add Binary Search Algorithm #490

wants to merge 3 commits into from

Conversation

j3r3mias
Copy link

@j3r3mias j3r3mias commented Oct 30, 2018

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.

  • I have read the Contribution guidelines and I am confident that my PR reflects them.
  • I have followed the commit guidelines for this project.
  • My code follows the standard code structure.
  • This pull request has a descriptive title. For example, {Tag}: Add {Algorithm/DS name} [{Language}], not Update README.md or Added new code.
  • This pull request will be closed if I fail to update it even once in a continuous time span of 7 days.
  • This pull request shall only be reviewed and merged once all the checks passes. No maintainer or supporter shall be obliged to review it before this condition is met.
  • I have mentioned the issue number correctly (with hyperlink) in this pull request description.

After you submit your pull request, DO NOT click the 'Update Branch' button.

This add Binary Search Algorithm which return the index of the searched item.

Closes #53
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);
Copy link
Member

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;
 }

#include <stdio.h>

int binarySearch(int arr[], int start, int end, int item)
{
Copy link
Member

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.

}

int main()
{
Copy link
Member

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.

@sangamcse
Copy link
Member

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: all.cpplint.

@sangamcse
Copy link
Member

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: all.cpplint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Data Structure] Binary Search Tree [C]
3 participants