mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 05:59:22 +08:00
style: enable MultipleVariableDeclarations
in checkstyle (#5175)
Co-authored-by: vaibhav <vaibhav.waghmare@techprescient.com>
This commit is contained in:
@ -13,13 +13,16 @@ public final class BinarySearch2dArray {
|
||||
}
|
||||
|
||||
static int[] BinarySearch(int[][] arr, int target) {
|
||||
int rowCount = arr.length, colCount = arr[0].length;
|
||||
int rowCount = arr.length;
|
||||
int colCount = arr[0].length;
|
||||
|
||||
if (rowCount == 1) {
|
||||
return binarySearch(arr, target, 0, 0, colCount);
|
||||
}
|
||||
|
||||
int startRow = 0, endRow = rowCount - 1, midCol = colCount / 2;
|
||||
int startRow = 0;
|
||||
int endRow = rowCount - 1;
|
||||
int midCol = colCount / 2;
|
||||
|
||||
while (startRow < endRow - 1) {
|
||||
int midRow = startRow + (endRow - startRow) / 2; // getting the index of middle row
|
||||
|
@ -23,7 +23,8 @@ class InterpolationSearch {
|
||||
*/
|
||||
public int find(int[] array, int key) {
|
||||
// Find indexes of two corners
|
||||
int start = 0, end = (array.length - 1);
|
||||
int start = 0;
|
||||
int end = (array.length - 1);
|
||||
|
||||
// Since array is sorted, an element present
|
||||
// in array must be in range defined by corner
|
||||
|
@ -32,7 +32,10 @@ public final class IterativeBinarySearch implements SearchAlgorithm {
|
||||
*/
|
||||
@Override
|
||||
public <T extends Comparable<T>> int find(T[] array, T key) {
|
||||
int l, r, k, cmp;
|
||||
int l;
|
||||
int r;
|
||||
int k;
|
||||
int cmp;
|
||||
|
||||
l = 0;
|
||||
r = array.length - 1;
|
||||
|
@ -42,7 +42,8 @@ public final class LinearSearchThread {
|
||||
class Searcher extends Thread {
|
||||
|
||||
private final int[] arr;
|
||||
private final int left, right;
|
||||
private final int left;
|
||||
private final int right;
|
||||
private final int x;
|
||||
private boolean found;
|
||||
|
||||
|
@ -57,7 +57,10 @@ public final class SaddlebackSearch {
|
||||
// TODO Auto-generated method stub
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int[][] arr;
|
||||
int i, j, rows = sc.nextInt(), col = sc.nextInt();
|
||||
int i;
|
||||
int j;
|
||||
int rows = sc.nextInt();
|
||||
int col = sc.nextInt();
|
||||
arr = new int[rows][col];
|
||||
for (i = 0; i < rows; i++) {
|
||||
for (j = 0; j < col; j++) {
|
||||
|
Reference in New Issue
Block a user