Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit c42b1c9

Browse files
authored
style: enable ParameterName in CheckStyle. (TheAlgorithms#5196)
* Enabled: ParameterName in CheckStyle. * Refactored to fix bug caused by selfAssignment of variables in VectorCrossproduct class
1 parent 2568b96 commit c42b1c9

23 files changed

+139
-139
lines changed

checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<module name="MemberName"/>
115115
<module name="MethodName"/>
116116
<module name="PackageName"/>
117-
<!-- TODO <module name="ParameterName"/> -->
117+
<module name="ParameterName"/>
118118
<module name="StaticVariableName"/>
119119
<!-- TODO <module name="TypeName"/> -->
120120

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ public class PowerSum {
1111
private int count = 0;
1212
private int sum = 0;
1313

14-
public int powSum(int N, int X) {
15-
sum(N, X, 1);
14+
public int powSum(int n, int x) {
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.
22-
if (sum == N) {
22+
if (sum == n) {
2323
count++;
2424
return;
2525
} // we will be adding next natural number raised to X only if on adding it in sum the
2626
// result is less than N.
27-
else if (sum + power(i, X) <= N) {
28-
sum += power(i, X);
29-
sum(N, X, i + 1);
27+
else if (sum + power(i, x) <= n) {
28+
sum += power(i, x);
29+
sum(n, x, i + 1);
3030
// backtracking and removing the number added last since no possible combination is
3131
// there with it.
32-
sum -= power(i, X);
32+
sum -= power(i, x);
3333
}
34-
if (power(i, X) < N) {
34+
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/conversions/RomanToInteger.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ private RomanToInteger() {
2424
/**
2525
* This function convert Roman number into Integer
2626
*
27-
* @param A Roman number string
27+
* @param a Roman number string
2828
* @return integer
2929
*/
30-
public static int romanToInt(String A) {
31-
A = A.toUpperCase();
30+
public static int romanToInt(String a) {
31+
a = a.toUpperCase();
3232
char prev = ' ';
3333

3434
int sum = 0;
3535

3636
int newPrev = 0;
37-
for (int i = A.length() - 1; i >= 0; i--) {
38-
char c = A.charAt(i);
37+
for (int i = a.length() - 1; i >= 0; i--) {
38+
char c = a.charAt(i);
3939

4040
if (prev != ' ') {
41-
// checking current Number greater then previous or not
41+
// checking current Number greater than previous or not
4242
newPrev = ROMAN_TO_INT.get(prev) > newPrev ? ROMAN_TO_INT.get(prev) : newPrev;
4343
}
4444

4545
int currentNum = ROMAN_TO_INT.get(c);
4646

47-
// if current number greater then prev max previous then add
47+
// if current number greater than prev max previous then add
4848
if (currentNum >= newPrev) {
4949
sum += currentNum;
5050
} else {
51-
// subtract upcoming number until upcoming number not greater then prev max
51+
// subtract upcoming number until upcoming number not greater than prev max
5252
sum -= currentNum;
5353
}
5454

src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGrapfDFS.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public final class BipartiteGrapfDFS {
1818
private BipartiteGrapfDFS() {
1919
}
2020

21-
private static boolean bipartite(int V, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
21+
private static boolean bipartite(int v, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
2222
if (color[node] == -1) {
2323
color[node] = 1;
2424
}
2525
for (Integer it : adj.get(node)) {
2626
if (color[it] == -1) {
2727
color[it] = 1 - color[node];
28-
if (!bipartite(V, adj, color, it)) {
28+
if (!bipartite(v, adj, color, it)) {
2929
return false;
3030
}
3131
} else if (color[it] == color[node]) {
@@ -35,14 +35,14 @@ private static boolean bipartite(int V, ArrayList<ArrayList<Integer>> adj, int[]
3535
return true;
3636
}
3737

38-
public static boolean isBipartite(int V, ArrayList<ArrayList<Integer>> adj) {
38+
public static boolean isBipartite(int v, ArrayList<ArrayList<Integer>> adj) {
3939
// Code here
40-
int[] color = new int[V + 1];
40+
int[] color = new int[v + 1];
4141
Arrays.fill(color, -1);
4242

43-
for (int i = 0; i < V; i++) {
43+
for (int i = 0; i < v; i++) {
4444
if (color[i] == -1) {
45-
if (!bipartite(V, adj, color, i)) {
45+
if (!bipartite(v, adj, color, i)) {
4646
return false;
4747
}
4848
}

src/main/java/com/thealgorithms/datastructures/graphs/FloydWarshall.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public FloydWarshall(int numberofvertices) {
1515
this.numberofvertices = numberofvertices;
1616
}
1717

18-
public void floydwarshall(int[][] AdjacencyMatrix) { // calculates all the distances from source to destination vertex
18+
public void floydwarshall(int[][] adjacencyMatrix) { // calculates all the distances from source to destination vertex
1919
for (int source = 1; source <= numberofvertices; source++) {
2020
for (int destination = 1; destination <= numberofvertices; destination++) {
21-
distanceMatrix[source][destination] = AdjacencyMatrix[source][destination];
21+
distanceMatrix[source][destination] = adjacencyMatrix[source][destination];
2222
}
2323
}
2424
for (int intermediate = 1; intermediate <= numberofvertices; intermediate++) {

src/main/java/com/thealgorithms/datastructures/graphs/TarjansAlgorithm.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,28 @@ public class TarjansAlgorithm {
6060

6161
private List<List<Integer>> sccList = new ArrayList<List<Integer>>();
6262

63-
public List<List<Integer>> stronglyConnectedComponents(int V, List<List<Integer>> graph) {
63+
public List<List<Integer>> stronglyConnectedComponents(int v, List<List<Integer>> graph) {
6464

6565
// Initially all vertices as unvisited, insertion and low time are undefined
6666

6767
// insertionTime:Time when a node is visited 1st time while DFS traversal
6868

6969
// lowTime: indicates the earliest visited vertex (the vertex with minimum insertion time)
7070
// that can be reached from a subtree rooted with a particular node.
71-
int[] lowTime = new int[V];
72-
int[] insertionTime = new int[V];
73-
for (int i = 0; i < V; i++) {
71+
int[] lowTime = new int[v];
72+
int[] insertionTime = new int[v];
73+
for (int i = 0; i < v; i++) {
7474
insertionTime[i] = -1;
7575
lowTime[i] = -1;
7676
}
7777

7878
// To check if element is present in stack
79-
boolean[] isInStack = new boolean[V];
79+
boolean[] isInStack = new boolean[v];
8080

8181
// Store nodes during DFS
8282
Stack<Integer> st = new Stack<Integer>();
8383

84-
for (int i = 0; i < V; i++) {
84+
for (int i = 0; i < v; i++) {
8585
if (insertionTime[i] == -1) stronglyConnCompsUtil(i, lowTime, insertionTime, isInStack, st, graph);
8686
}
8787

src/main/java/com/thealgorithms/datastructures/hashmap/hashing/GenericHashMapUsingArray.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public GenericHashMapUsingArray() {
1919
// 75, then adding 76th item it will double the size, copy all elements
2020
// & then add 76th item.
2121

22-
private void initBuckets(int N) {
23-
buckets = new LinkedList[N];
22+
private void initBuckets(int n) {
23+
buckets = new LinkedList[n];
2424
for (int i = 0; i < buckets.length; i++) {
2525
buckets[i] = new LinkedList<>();
2626
}

src/main/java/com/thealgorithms/datastructures/lists/Merge_K_SortedLinkedlist.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public class Merge_K_SortedLinkedlist {
1313
* This function merge K sorted LinkedList
1414
*
1515
* @param a array of LinkedList
16-
* @param N size of array
16+
* @param n size of array
1717
* @return node
1818
*/
19-
Node mergeKList(Node[] a, int N) {
19+
Node mergeKList(Node[] a, int n) {
2020
// Min Heap
2121
PriorityQueue<Node> min = new PriorityQueue<>(Comparator.comparingInt(x -> x.data));
2222

2323
// adding head of all linkedList in min heap
24-
min.addAll(Arrays.asList(a).subList(0, N));
24+
min.addAll(Arrays.asList(a).subList(0, n));
2525

2626
// Make new head among smallest heads in K linkedList
2727
Node head = min.poll();

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ public final int constructTree(int[] arr, int start, int end, int index) {
3232

3333
/* A function which will update the value at a index i. This will be called by the
3434
update function internally*/
35-
private void updateTree(int start, int end, int index, int diff, int seg_index) {
35+
private void updateTree(int start, int end, int index, int diff, int segIndex) {
3636
if (index < start || index > end) {
3737
return;
3838
}
3939

40-
this.segTree[seg_index] += diff;
40+
this.segTree[segIndex] += diff;
4141
if (start != end) {
4242
int mid = start + (end - start) / 2;
43-
updateTree(start, mid, index, diff, seg_index * 2 + 1);
44-
updateTree(mid + 1, end, index, diff, seg_index * 2 + 2);
43+
updateTree(start, mid, index, diff, segIndex * 2 + 1);
44+
updateTree(mid + 1, end, index, diff, segIndex * 2 + 2);
4545
}
4646
}
4747

@@ -58,17 +58,17 @@ public void update(int index, int value) {
5858

5959
/* A function to get the sum of the elements from index l to index r. This will be called
6060
* internally*/
61-
private int getSumTree(int start, int end, int q_start, int q_end, int seg_index) {
62-
if (q_start <= start && q_end >= end) {
63-
return this.segTree[seg_index];
61+
private int getSumTree(int start, int end, int qStart, int qEnd, int segIndex) {
62+
if (qStart <= start && qEnd >= end) {
63+
return this.segTree[segIndex];
6464
}
6565

66-
if (q_start > end || q_end < start) {
66+
if (qStart > end || qEnd < start) {
6767
return 0;
6868
}
6969

7070
int mid = start + (end - start) / 2;
71-
return (getSumTree(start, mid, q_start, q_end, seg_index * 2 + 1) + getSumTree(mid + 1, end, q_start, q_end, seg_index * 2 + 2));
71+
return (getSumTree(start, mid, qStart, qEnd, segIndex * 2 + 1) + getSumTree(mid + 1, end, qStart, qEnd, segIndex * 2 + 2));
7272
}
7373

7474
/* A function to query the sum of the subarray [start...end]*/

src/main/java/com/thealgorithms/divideandconquer/BinaryExponentiation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public static long calculatePower(long x, long y) {
2727
}
2828

2929
// iterative function to calculate a to the power of b
30-
long power(long N, long M) {
31-
long power = N;
30+
long power(long n, long m) {
31+
long power = n;
3232
long sum = 1;
33-
while (M > 0) {
34-
if ((M & 1) == 1) {
33+
while (m > 0) {
34+
if ((m & 1) == 1) {
3535
sum *= power;
3636
}
3737
power = power * power;
38-
M = M >> 1;
38+
m = m >> 1;
3939
}
4040
return sum;
4141
}

0 commit comments

Comments
 (0)