diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index 95977349..dd9d267b 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -8,9 +8,6 @@ - - - diff --git a/src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java b/src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java index e7a54f21..a0882007 100644 --- a/src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java +++ b/src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java @@ -97,7 +97,7 @@ public class LongestIncreasingSubsequence { return end + 1; } while (left < right - 1) { - int middle = (left + right) / 2; + final int middle = (left + right) >>> 1; if (t[middle] < key) { left = middle; } else { diff --git a/src/main/java/com/thealgorithms/misc/RangeInSortedArray.java b/src/main/java/com/thealgorithms/misc/RangeInSortedArray.java index af2ca4dd..d0d543d3 100644 --- a/src/main/java/com/thealgorithms/misc/RangeInSortedArray.java +++ b/src/main/java/com/thealgorithms/misc/RangeInSortedArray.java @@ -26,7 +26,7 @@ public class RangeInSortedArray { if (left > right) { return; } - int mid = (left + right) / 2; + int mid = (left + right) >>> 1; if (nums[mid] > key) { alteredBinSearch(nums, key, left, mid - 1, range, goLeft); } else if (nums[mid] < key) { @@ -52,7 +52,7 @@ public class RangeInSortedArray { // of 'key' public static void alteredBinSearchIter(int[] nums, int key, int left, int right, int[] range, boolean goLeft) { while (left <= right) { - int mid = (left + right) / 2; + final int mid = (left + right) >>> 1; if (nums[mid] > key) { right = mid - 1; } else if (nums[mid] < key) { @@ -84,7 +84,7 @@ public class RangeInSortedArray { public static int getLessThan(int[] nums, int key, int left, int right) { int count = 0; while (left <= right) { - int mid = (left + right) / 2; + final int mid = (left + right) >>> 1; if (nums[mid] > key) { right = mid - 1; } else if (nums[mid] <= key) { diff --git a/src/main/java/com/thealgorithms/sorts/BinaryInsertionSort.java b/src/main/java/com/thealgorithms/sorts/BinaryInsertionSort.java index 1c2dce65..13076c61 100644 --- a/src/main/java/com/thealgorithms/sorts/BinaryInsertionSort.java +++ b/src/main/java/com/thealgorithms/sorts/BinaryInsertionSort.java @@ -10,7 +10,7 @@ public class BinaryInsertionSort { int high = i - 1; while (low <= high) { - int mid = (low + high) / 2; + final int mid = (low + high) >>> 1; if (temp < array[mid]) { high = mid - 1; } else { diff --git a/src/main/java/com/thealgorithms/sorts/SlowSort.java b/src/main/java/com/thealgorithms/sorts/SlowSort.java index 1ab8ceea..dcd426b3 100644 --- a/src/main/java/com/thealgorithms/sorts/SlowSort.java +++ b/src/main/java/com/thealgorithms/sorts/SlowSort.java @@ -16,7 +16,7 @@ public class SlowSort implements SortAlgorithm { if (SortUtils.greaterOrEqual(i, j)) { return; } - int m = (i + j) / 2; + final int m = (i + j) >>> 1; sort(array, i, m); sort(array, m + 1, j); if (SortUtils.less(array[j], array[m])) {