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 #6291
base: master
Are you sure you want to change the base?
Binary Search #6291
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.
please make your code easier to read by using blank lines.
int solve(int arr[],int n,int target){ | ||
int low=0; | ||
int high=n-1; | ||
while(low<=high){ |
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.
if low is equal to high, so in this case target is not exist, the loop condition should be only (low < high)
If low== high means there is only one element in array. So what if that
element is equals to target.
…On Wed, Oct 27, 2021, 7:37 PM well ***@***.***> wrote:
***@***.**** requested changes on this pull request.
please make your code easier to read by using blank lines.
------------------------------
In code/algorithm_applications/src/binary_search/Binary Search.cpp
<#6291 (comment)>:
> @@ -0,0 +1,32 @@
+#include<bits/stdc++.h>
+using namespace std;
+int solve(int arr[],int n,int target){
+ int low=0;
+ int high=n-1;
+ while(low<=high){
if *low* is equal to *high*, so in this case target is not exist, the
loop condition should be only (low < high)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6291 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV34TA3UAPFPP5WOOYW64KTUJAITPANCNFSM5GR4F26Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
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.
This directory is for applications of specific algorithms. You may need to move the implementation of Binary Search to another directory.
Fixes issue:
Changes: