X Tutup
The Wayback Machine - https://web.archive.org/web/20200608230858/https://github.com/TheAlgorithms/Java/pull/1243/files
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

Create UpperBound.java #1243

Open
wants to merge 2 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -0,0 +1,20 @@
public class LowerBound {

public static void LowerBound(String[] args) {
}

private static int lowerBound(int[] array, int length, int value) {
int low = 0;
int high = length;
while (low < high) {
final int mid = (low + high) / 2;
//checks if the value is less than middle element of the array
if (value <= array[mid]) {
high = mid;
} else {
low = mid + 1;
}
}
return low;
}
}
@@ -0,0 +1,19 @@
public class UpperBound {
public static void UpperBound(String[] args) {

}

private static int upper_bound(int arr[], int value) {
int low = 0;
int high = arr.length;
while (low < high) {
int mid = (low + high) / 2;
if (value >= arr[mid]) {
low = mid + 1;
} else {
high = mid;
}
}
return low;
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.
X Tutup