mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 11:10:08 +08:00
style: enable NeedBraces
in checkstyle (#5227)
* enable style NeedBraces * style: enable NeedBraces in checkstyle --------- Co-authored-by: Samuel Facchinello <samuel.facchinello@piksel.com>
This commit is contained in:

committed by
GitHub

parent
51fcc66345
commit
87b17e0571
@ -24,22 +24,23 @@ public final class OrderAgnosticBinarySearch {
|
||||
int middle = start + (end - start) / 2;
|
||||
|
||||
// Check if the desired element is present at the middle position
|
||||
if (arr[middle] == target) return middle; // returns the index of the middle element
|
||||
|
||||
// Ascending order
|
||||
if (ascOrd) {
|
||||
if (arr[middle] < target)
|
||||
start = middle + 1;
|
||||
else
|
||||
end = middle - 1;
|
||||
if (arr[middle] == target) {
|
||||
return middle; // returns the index of the middle element
|
||||
}
|
||||
|
||||
// Descending order
|
||||
else {
|
||||
if (arr[middle] > target)
|
||||
if (ascOrd) {
|
||||
// Ascending order
|
||||
if (arr[middle] < target) {
|
||||
start = middle + 1;
|
||||
else
|
||||
} else {
|
||||
end = middle - 1;
|
||||
}
|
||||
} else {
|
||||
// Descending order
|
||||
if (arr[middle] > target) {
|
||||
start = middle + 1;
|
||||
} else {
|
||||
end = middle - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Element is not present
|
||||
|
Reference in New Issue
Block a user