Skip to content

Commit 295e743

Browse files
authored
style: enable MethodName in CheckStyle (#5182)
enabled: MethodName in CheckStyle
1 parent ea4dc15 commit 295e743

File tree

53 files changed

+225
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+225
-225
lines changed

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<module name="LocalFinalVariableName"/>
113113
<!-- TODO <module name="LocalVariableName"/> -->
114114
<!-- TODO <module name="MemberName"/> -->
115-
<!-- TODO <module name="MethodName"/> -->
115+
<module name="MethodName"/>
116116
<module name="PackageName"/>
117117
<!-- TODO <module name="ParameterName"/> -->
118118
<module name="StaticVariableName"/>

src/main/java/com/thealgorithms/backtracking/PowerSum.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public class PowerSum {
1212
private int sum = 0;
1313

1414
public int powSum(int N, int X) {
15-
Sum(N, X, 1);
15+
sum(N, X, 1);
1616
return count;
1717
}
1818

1919
// here i is the natural number which will be raised by X and added in sum.
20-
public void Sum(int N, int X, int i) {
20+
public void sum(int N, int X, int i) {
2121
// if sum is equal to N that is one of our answer and count is increased.
2222
if (sum == N) {
2323
count++;
@@ -26,15 +26,15 @@ public void Sum(int N, int X, int i) {
2626
// result is less than N.
2727
else if (sum + power(i, X) <= N) {
2828
sum += power(i, X);
29-
Sum(N, X, i + 1);
29+
sum(N, X, i + 1);
3030
// backtracking and removing the number added last since no possible combination is
3131
// there with it.
3232
sum -= power(i, X);
3333
}
3434
if (power(i, X) < N) {
3535
// calling the sum function with next natural number after backtracking if when it is
3636
// raised to X is still less than X.
37-
Sum(N, X, i + 1);
37+
sum(N, X, i + 1);
3838
}
3939
}
4040

src/main/java/com/thealgorithms/ciphers/DES.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private String[] getSubkeys(String originalKey) {
106106
return subKeys;
107107
}
108108

109-
private String XOR(String a, String b) {
109+
private String xOR(String a, String b) {
110110
int i;
111111
int l = a.length();
112112
StringBuilder xor = new StringBuilder();
@@ -143,7 +143,7 @@ private String feistel(String messageBlock, String key) {
143143
for (i = 0; i < 48; i++) {
144144
expandedKey.append(messageBlock.charAt(EXPANSION[i] - 1));
145145
}
146-
String mixedKey = XOR(expandedKey.toString(), key);
146+
String mixedKey = xOR(expandedKey.toString(), key);
147147
StringBuilder substitutedString = new StringBuilder();
148148

149149
// Let us now use the s-boxes to transform each 6 bit (length here) block to 4 bits
@@ -175,7 +175,7 @@ private String encryptBlock(String message, String[] keys) {
175175
// Iterate 16 times
176176
for (i = 0; i < 16; i++) {
177177
String Ln = R0; // Previous Right block
178-
String Rn = XOR(L0, feistel(R0, keys[i]));
178+
String Rn = xOR(L0, feistel(R0, keys[i]));
179179
L0 = Ln;
180180
R0 = Rn;
181181
}

src/main/java/com/thealgorithms/datastructures/heaps/LeftistHeap.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void insert(int a) {
9191
}
9292

9393
// Returns and removes the minimum element in the heap
94-
public int extract_min() {
94+
public int extractMin() {
9595
// If is empty return -1
9696
if (isEmpty()) return -1;
9797

@@ -101,17 +101,17 @@ public int extract_min() {
101101
}
102102

103103
// Function returning a list of an in order traversal of the data structure
104-
public ArrayList<Integer> in_order() {
104+
public ArrayList<Integer> inOrder() {
105105
ArrayList<Integer> lst = new ArrayList<>();
106-
in_order_aux(root, lst);
106+
inOrderAux(root, lst);
107107
return new ArrayList<>(lst);
108108
}
109109

110110
// Auxiliary function for in_order
111-
private void in_order_aux(Node n, ArrayList<Integer> lst) {
111+
private void inOrderAux(Node n, ArrayList<Integer> lst) {
112112
if (n == null) return;
113-
in_order_aux(n.left, lst);
113+
inOrderAux(n.left, lst);
114114
lst.add(n.element);
115-
in_order_aux(n.right, lst);
115+
inOrderAux(n.right, lst);
116116
}
117117
}

src/main/java/com/thealgorithms/datastructures/trees/GenericTree.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ private static final class Node {
2525
private final Node root;
2626
public GenericTree() { // Constructor
2727
Scanner scn = new Scanner(System.in);
28-
root = create_treeG(null, 0, scn);
28+
root = createTreeG(null, 0, scn);
2929
}
3030

31-
private Node create_treeG(Node node, int childIndex, Scanner scanner) {
31+
private Node createTreeG(Node node, int childIndex, Scanner scanner) {
3232
// display
3333
if (node == null) {
3434
System.out.println("Enter root's data");
@@ -41,7 +41,7 @@ private Node create_treeG(Node node, int childIndex, Scanner scanner) {
4141
System.out.println("number of children");
4242
int number = scanner.nextInt();
4343
for (int i = 0; i < number; i++) {
44-
Node child = create_treeG(node, i, scanner);
44+
Node child = createTreeG(node, i, scanner);
4545
node.child.add(child);
4646
}
4747
return node;
@@ -51,17 +51,17 @@ private Node create_treeG(Node node, int childIndex, Scanner scanner) {
5151
* Function to display the generic tree
5252
*/
5353
public void display() { // Helper function
54-
display_1(root);
54+
display1(root);
5555
}
5656

57-
private void display_1(Node parent) {
57+
private void display1(Node parent) {
5858
System.out.print(parent.data + "=>");
5959
for (int i = 0; i < parent.child.size(); i++) {
6060
System.out.print(parent.child.get(i).data + " ");
6161
}
6262
System.out.println(".");
6363
for (int i = 0; i < parent.child.size(); i++) {
64-
display_1(parent.child.get(i));
64+
display1(parent.child.get(i));
6565
}
6666
}
6767

src/main/java/com/thealgorithms/datastructures/trees/nearestRightKey.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ private NearestRightKey() {
88
}
99

1010
public static void main(String[] args) {
11-
NRKTree root = BuildTree();
11+
NRKTree root = buildTree();
1212
Scanner sc = new Scanner(System.in);
1313
System.out.print("Enter first number: ");
1414
int inputX0 = sc.nextInt();
@@ -17,7 +17,7 @@ public static void main(String[] args) {
1717
sc.close();
1818
}
1919

20-
public static NRKTree BuildTree() {
20+
public static NRKTree buildTree() {
2121
int randomX = ThreadLocalRandom.current().nextInt(0, 100 + 1);
2222
NRKTree root = new NRKTree(null, null, randomX);
2323

src/main/java/com/thealgorithms/dynamicprogramming/KadaneAlgorithm.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public final class KadaneAlgorithm {
1010
private KadaneAlgorithm() {
1111
}
1212

13-
public static boolean max_Sum(int[] a, int predicted_answer) {
13+
public static boolean maxSum(int[] a, int predicted_answer) {
1414
int sum = a[0];
1515
int running_sum = 0;
1616
for (int k : a) {

src/main/java/com/thealgorithms/dynamicprogramming/LongestAlternatingSubsequence.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private LongestAlternatingSubsequence() {
1616
}
1717

1818
/* Function to return longest alternating subsequence length*/
19-
static int AlternatingLength(int[] arr, int n) {
19+
static int alternatingLength(int[] arr, int n) {
2020
/*
2121
2222
las[i][0] = Length of the longest
@@ -68,6 +68,6 @@ public static void main(String[] args) {
6868
int[] arr = {10, 22, 9, 33, 49, 50, 31, 60};
6969
int n = arr.length;
7070
System.out.println("Length of Longest "
71-
+ "alternating subsequence is " + AlternatingLength(arr, n));
71+
+ "alternating subsequence is " + alternatingLength(arr, n));
7272
}
7373
}

src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static int upperBound(int[] ar, int l, int r, int key) {
2020
return r;
2121
}
2222

23-
public static int LIS(int[] array) {
23+
public static int lis(int[] array) {
2424
int N = array.length;
2525
if (N == 0) {
2626
return 0;

src/main/java/com/thealgorithms/dynamicprogramming/LongestPalindromicSubsequence.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public static void main(String[] args) {
1212
String a = "BBABCBCAB";
1313
String b = "BABCBAB";
1414

15-
String aLPS = LPS(a);
16-
String bLPS = LPS(b);
15+
String aLPS = lps(a);
16+
String bLPS = lps(b);
1717

1818
System.out.println(a + " => " + aLPS);
1919
System.out.println(b + " => " + bLPS);
2020
}
2121

22-
public static String LPS(String original) throws IllegalArgumentException {
22+
public static String lps(String original) throws IllegalArgumentException {
2323
StringBuilder reverse = new StringBuilder(original);
2424
reverse = reverse.reverse();
2525
return recursiveLPS(original, reverse.toString());

src/main/java/com/thealgorithms/dynamicprogramming/LongestPalindromicSubstring.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ public static void main(String[] args) {
1111
String a = "babad";
1212
String b = "cbbd";
1313

14-
String aLPS = LPS(a);
15-
String bLPS = LPS(b);
14+
String aLPS = lps(a);
15+
String bLPS = lps(b);
1616

1717
System.out.println(a + " => " + aLPS);
1818
System.out.println(b + " => " + bLPS);
1919
}
2020

21-
private static String LPS(String input) {
21+
private static String lps(String input) {
2222
if (input == null || input.length() == 0) {
2323
return input;
2424
}

src/main/java/com/thealgorithms/dynamicprogramming/MatrixChainRecursiveTopDownMemoisation.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public final class MatrixChainRecursiveTopDownMemoisation {
1010
private MatrixChainRecursiveTopDownMemoisation() {
1111
}
1212

13-
static int Memoized_Matrix_Chain(int[] p) {
13+
static int memoizedMatrixChain(int[] p) {
1414
int n = p.length;
1515
int[][] m = new int[n][n];
1616
for (int i = 0; i < n; i++) {
1717
for (int j = 0; j < n; j++) {
1818
m[i][j] = Integer.MAX_VALUE;
1919
}
2020
}
21-
return Lookup_Chain(m, p, 1, n - 1);
21+
return lookupChain(m, p, 1, n - 1);
2222
}
2323

24-
static int Lookup_Chain(int[][] m, int[] p, int i, int j) {
24+
static int lookupChain(int[][] m, int[] p, int i, int j) {
2525
if (i == j) {
2626
m[i][j] = 0;
2727
return m[i][j];
@@ -30,7 +30,7 @@ static int Lookup_Chain(int[][] m, int[] p, int i, int j) {
3030
return m[i][j];
3131
} else {
3232
for (int k = i; k < j; k++) {
33-
int q = Lookup_Chain(m, p, i, k) + Lookup_Chain(m, p, k + 1, j) + (p[i - 1] * p[k] * p[j]);
33+
int q = lookupChain(m, p, i, k) + lookupChain(m, p, k + 1, j) + (p[i - 1] * p[k] * p[j]);
3434
if (q < m[i][j]) {
3535
m[i][j] = q;
3636
}
@@ -43,6 +43,6 @@ static int Lookup_Chain(int[][] m, int[] p, int i, int j) {
4343
// respectively output should be Minimum number of multiplications is 38
4444
public static void main(String[] args) {
4545
int[] arr = {1, 2, 3, 4, 5};
46-
System.out.println("Minimum number of multiplications is " + Memoized_Matrix_Chain(arr));
46+
System.out.println("Minimum number of multiplications is " + memoizedMatrixChain(arr));
4747
}
4848
}

src/main/java/com/thealgorithms/dynamicprogramming/WineProblem.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ private WineProblem() {
1616

1717
// Method 1: Using Recursion
1818
// Time Complexity=0(2^N) Space Complexity=Recursion extra space
19-
public static int WPRecursion(int[] arr, int si, int ei) {
19+
public static int wpRecursion(int[] arr, int si, int ei) {
2020
int n = arr.length;
2121
int year = (n - (ei - si + 1)) + 1;
2222
if (si == ei) {
2323
return arr[si] * year;
2424
}
2525

26-
int start = WPRecursion(arr, si + 1, ei) + arr[si] * year;
27-
int end = WPRecursion(arr, si, ei - 1) + arr[ei] * year;
26+
int start = wpRecursion(arr, si + 1, ei) + arr[si] * year;
27+
int end = wpRecursion(arr, si, ei - 1) + arr[ei] * year;
2828

2929
return Math.max(start, end);
3030
}
3131

3232
// Method 2: Top-Down DP(Memoization)
3333
// Time Complexity=0(N*N) Space Complexity=0(N*N)+Recursion extra space
34-
public static int WPTD(int[] arr, int si, int ei, int[][] strg) {
34+
public static int wptd(int[] arr, int si, int ei, int[][] strg) {
3535
int n = arr.length;
3636
int year = (n - (ei - si + 1)) + 1;
3737
if (si == ei) {
@@ -41,8 +41,8 @@ public static int WPTD(int[] arr, int si, int ei, int[][] strg) {
4141
if (strg[si][ei] != 0) {
4242
return strg[si][ei];
4343
}
44-
int start = WPTD(arr, si + 1, ei, strg) + arr[si] * year;
45-
int end = WPTD(arr, si, ei - 1, strg) + arr[ei] * year;
44+
int start = wptd(arr, si + 1, ei, strg) + arr[si] * year;
45+
int end = wptd(arr, si, ei - 1, strg) + arr[ei] * year;
4646

4747
int ans = Math.max(start, end);
4848

@@ -53,7 +53,7 @@ public static int WPTD(int[] arr, int si, int ei, int[][] strg) {
5353

5454
// Method 3: Bottom-Up DP(Tabulation)
5555
// Time Complexity=0(N*N/2)->0(N*N) Space Complexity=0(N*N)
56-
public static int WPBU(int[] arr) {
56+
public static int wpbu(int[] arr) {
5757
int n = arr.length;
5858
int[][] strg = new int[n][n];
5959

@@ -76,9 +76,9 @@ public static int WPBU(int[] arr) {
7676

7777
public static void main(String[] args) {
7878
int[] arr = {2, 3, 5, 1, 4};
79-
System.out.println("Method 1: " + WPRecursion(arr, 0, arr.length - 1));
80-
System.out.println("Method 2: " + WPTD(arr, 0, arr.length - 1, new int[arr.length][arr.length]));
81-
System.out.println("Method 3: " + WPBU(arr));
79+
System.out.println("Method 1: " + wpRecursion(arr, 0, arr.length - 1));
80+
System.out.println("Method 2: " + wptd(arr, 0, arr.length - 1, new int[arr.length][arr.length]));
81+
System.out.println("Method 3: " + wpbu(arr));
8282
}
8383
}
8484
// Memoization vs Tabulation : https://www.geeksforgeeks.org/tabulation-vs-memoization/

src/main/java/com/thealgorithms/maths/SquareRootWithBabylonianMethod.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private SquareRootWithBabylonianMethod() {
1010
* @param num contains elements
1111
* @return the square root of num
1212
*/
13-
public static float square_Root(float num) {
13+
public static float squareRoot(float num) {
1414
float a = num;
1515
float b = 1;
1616
double e = 0.000001;

src/main/java/com/thealgorithms/maths/TrinomialTriangle.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public final class TrinomialTriangle {
1111
private TrinomialTriangle() {
1212
}
1313

14-
public static int TrinomialValue(int n, int k) {
14+
public static int trinomialValue(int n, int k) {
1515
if (n == 0 && k == 0) {
1616
return 1;
1717
}
@@ -20,17 +20,17 @@ public static int TrinomialValue(int n, int k) {
2020
return 0;
2121
}
2222

23-
return (TrinomialValue(n - 1, k - 1) + TrinomialValue(n - 1, k) + TrinomialValue(n - 1, k + 1));
23+
return (trinomialValue(n - 1, k - 1) + trinomialValue(n - 1, k) + trinomialValue(n - 1, k + 1));
2424
}
2525

2626
public static void printTrinomial(int n) {
2727
for (int i = 0; i < n; i++) {
2828
for (int j = -i; j <= 0; j++) {
29-
System.out.print(TrinomialValue(i, j) + " ");
29+
System.out.print(trinomialValue(i, j) + " ");
3030
}
3131

3232
for (int j = 1; j <= i; j++) {
33-
System.out.print(TrinomialValue(i, j) + " ");
33+
System.out.print(trinomialValue(i, j) + " ");
3434
}
3535

3636
System.out.println();

0 commit comments

Comments
 (0)