Skip to content

Commit ad72c28

Browse files
Remove unnecessary code (TheAlgorithms#4141)
1 parent 805f098 commit ad72c28

64 files changed

Lines changed: 125 additions & 322 deletions

Some content is hidden

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ public class Blowfish {
10791079
*/
10801080
private String hexToBin(String hex) {
10811081
String binary = "";
1082-
Long num;
1082+
long num;
10831083
String binary4B;
10841084
int n = hex.length();
10851085
for (int i = 0; i < n; i++) {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ static void validateDeterminant(int[][] keyMatrix, int n) {
160160
System.out.println(
161161
"Invalid key, as determinant = 0. Program Terminated"
162162
);
163-
return;
164163
}
165164
}
166165

src/main/java/com/thealgorithms/conversions/AnyBaseToAnyBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static String base2base(String n, int b1, int b2) {
175175
// If the remainder is a digit < 10, simply add it to
176176
// the left side of the new number.
177177
if (decimalValue % b2 < 10) {
178-
output = Integer.toString(decimalValue % b2) + output;
178+
output = decimalValue % b2 + output;
179179
} // If the remainder is >= 10, add a character with the
180180
// corresponding value to the new number. (A = 10, B = 11, C = 12, ...)
181181
else {

src/main/java/com/thealgorithms/conversions/OctalToDecimal.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public static void main(String args[]) {
3434
public static int convertOctalToDecimal(String inputOctal) {
3535
try {
3636
// Actual conversion of Octal to Decimal:
37-
Integer outputDecimal = Integer.parseInt(inputOctal, 8);
38-
return outputDecimal;
37+
return Integer.parseInt(inputOctal, 8);
3938
} catch (NumberFormatException ne) {
4039
// Printing a warning message if the input is not a valid octal
4140
// number:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void go() { // shows distance to all vertices // Interactive run for unde
7474
for (i = 0; i < v - 1; i++) {
7575
for (j = 0; j < e; j++) {
7676
if (
77-
(int) dist[arr[j].u] != Integer.MAX_VALUE &&
77+
dist[arr[j].u] != Integer.MAX_VALUE &&
7878
dist[arr[j].v] > dist[arr[j].u] + arr[j].w
7979
) {
8080
dist[arr[j].v] = dist[arr[j].u] + arr[j].w; // Update
@@ -85,7 +85,7 @@ public void go() { // shows distance to all vertices // Interactive run for unde
8585
// Final cycle for negative checking
8686
for (j = 0; j < e; j++) {
8787
if (
88-
(int) dist[arr[j].u] != Integer.MAX_VALUE &&
88+
dist[arr[j].u] != Integer.MAX_VALUE &&
8989
dist[arr[j].v] > dist[arr[j].u] + arr[j].w
9090
) {
9191
neg = 1;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private static boolean bipartite(
2828
for (Integer it : adj.get(node)) {
2929
if (color[it] == -1) {
3030
color[it] = 1 - color[node];
31-
if (bipartite(V, adj, color, it) == false) {
31+
if (!bipartite(V, adj, color, it)) {
3232
return false;
3333
}
3434
} else if (color[it] == color[node]) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int minDist(int dist[], Boolean Set[]) {
1212
int min = Integer.MAX_VALUE, min_index = -1;
1313

1414
for (int r = 0; r < k; r++) {
15-
if (Set[r] == false && dist[r] <= min) {
15+
if (!Set[r] && dist[r] <= min) {
1616
min = dist[r];
1717
min_index = r;
1818
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,7 @@ private boolean adjacencyOfEdgeDoesExist(int from, int to) {
154154
* @return whether or not the vertex exists
155155
*/
156156
public boolean vertexDoesExist(int aVertex) {
157-
if (aVertex >= 0 && aVertex < this.numberOfVertices()) {
158-
return true;
159-
} else {
160-
return false;
161-
}
157+
return aVertex >= 0 && aVertex < this.numberOfVertices();
162158
}
163159

164160
/**
@@ -343,14 +339,14 @@ public List<Integer> breadthFirstOrder(int startVertex) {
343339
public String toString() {
344340
String s = " ";
345341
for (int i = 0; i < this.numberOfVertices(); i++) {
346-
s = s + String.valueOf(i) + " ";
342+
s = s + i + " ";
347343
}
348344
s = s + " \n";
349345

350346
for (int i = 0; i < this.numberOfVertices(); i++) {
351-
s = s + String.valueOf(i) + " : ";
347+
s = s + i + " : ";
352348
for (int j = 0; j < this.numberOfVertices(); j++) {
353-
s = s + String.valueOf(this._adjacency[i][j]) + " ";
349+
s = s + this._adjacency[i][j] + " ";
354350
}
355351
s = s + "\n";
356352
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int minKey(int key[], Boolean mstSet[]) {
1717
int min = Integer.MAX_VALUE, min_index = -1;
1818

1919
for (int v = 0; v < V; v++) {
20-
if (mstSet[v] == false && key[v] < min) {
20+
if (!mstSet[v] && key[v] < min) {
2121
min = key[v];
2222
min_index = v;
2323
}
@@ -80,7 +80,7 @@ void primMST(int graph[][]) {
8080
{
8181
if (
8282
graph[u][v] != 0 &&
83-
mstSet[v] == false &&
83+
!mstSet[v] &&
8484
graph[u][v] < key[v]
8585
) {
8686
parent[v] = u;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private void stronglyConnCompsUtil(int u, int lowTime[], int insertionTime[],
114114
stronglyConnCompsUtil(n, lowTime, insertionTime, isInStack, st, graph);
115115
//update lowTime for the current node comparing lowtime of adj node
116116
lowTime[u] = Math.min(lowTime[u], lowTime[n]);
117-
} else if (isInStack[n] == true) {
117+
} else if (isInStack[n]) {
118118
//If adj node is in stack, update low
119119
lowTime[u] = Math.min(lowTime[u], insertionTime[n]);
120120
}

0 commit comments

Comments
 (0)