mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 05:59:22 +08:00
Remove unnecessary code (#4141)
This commit is contained in:
@ -88,7 +88,7 @@ public class BankersAlgorithm {
|
||||
while (count < totalProcess) {
|
||||
boolean foundSafeSystem = false;
|
||||
for (int m = 0; m < totalProcess; m++) {
|
||||
if (finishProcesses[m] == false) {
|
||||
if (!finishProcesses[m]) {
|
||||
int j;
|
||||
|
||||
for (j = 0; j < totalResources; j++) {
|
||||
@ -112,7 +112,7 @@ public class BankersAlgorithm {
|
||||
}
|
||||
|
||||
// If we could not find a next process in safe sequence.
|
||||
if (foundSafeSystem == false) {
|
||||
if (!foundSafeSystem) {
|
||||
System.out.print(
|
||||
"The system is not in the safe state because lack of resources"
|
||||
);
|
||||
|
@ -131,15 +131,7 @@ class Graph {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
neighbours != null
|
||||
? !neighbours.equals(vertex.neighbours)
|
||||
: vertex.neighbours != null
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return neighbours != null ? neighbours.equals(vertex.neighbours) : vertex.neighbours == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,7 +120,7 @@ class Trieac {
|
||||
}
|
||||
|
||||
// If prefix is present as a word.
|
||||
boolean isWord = (pCrawl.isWordEnd == true);
|
||||
boolean isWord = (pCrawl.isWordEnd);
|
||||
|
||||
// If prefix is last node of tree (has no
|
||||
// children)
|
||||
|
@ -139,7 +139,7 @@ public class LowestBasePalindrome {
|
||||
// If the remainder is a digit < 10, simply add it to
|
||||
// the left side of the new number.
|
||||
if (decimalValue % b2 < 10) {
|
||||
output = Integer.toString(decimalValue % b2) + output;
|
||||
output = decimalValue % b2 + output;
|
||||
} // If the remainder is >= 10, add a character with the
|
||||
// corresponding value to the new number. (A = 10, B = 11, C = 12, ...)
|
||||
else {
|
||||
|
@ -46,7 +46,7 @@ public class MiniMaxAlgorithm {
|
||||
"The best score for " +
|
||||
(isMaximizer ? "Maximizer" : "Minimizer") +
|
||||
" is " +
|
||||
String.valueOf(bestScore)
|
||||
bestScore
|
||||
);
|
||||
}
|
||||
|
||||
@ -88,14 +88,12 @@ public class MiniMaxAlgorithm {
|
||||
// (1 x 2) = 2; ((1 x 2) + 1) = 3
|
||||
// (2 x 2) = 4; ((2 x 2) + 1) = 5 ...
|
||||
if (verbose) {
|
||||
System.out.println(
|
||||
String.format(
|
||||
"From %02d and %02d, %s chooses %02d",
|
||||
System.out.printf(
|
||||
"From %02d and %02d, %s chooses %02d%n",
|
||||
score1,
|
||||
score2,
|
||||
(isMaximizer ? "Maximizer" : "Minimizer"),
|
||||
bestScore
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class PageRank {
|
||||
for (k = 1; k <= totalNodes; k++) {
|
||||
this.pagerank[k] = InitialPageRank;
|
||||
}
|
||||
System.out.printf("\n Initial PageRank Values , 0th Step \n");
|
||||
System.out.print("\n Initial PageRank Values , 0th Step \n");
|
||||
|
||||
for (k = 1; k <= totalNodes; k++) {
|
||||
System.out.printf(
|
||||
@ -113,7 +113,7 @@ class PageRank {
|
||||
}
|
||||
|
||||
// Display PageRank
|
||||
System.out.printf("\n Final Page Rank : \n");
|
||||
System.out.print("\n Final Page Rank : \n");
|
||||
for (k = 1; k <= totalNodes; k++) {
|
||||
System.out.printf(
|
||||
" Page Rank of " + k + " is :\t" + this.pagerank[k] + "\n"
|
||||
|
@ -40,7 +40,7 @@ public class RemoveDuplicateFromString {
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (sb.toString().indexOf(s.charAt(i)) == -1) {
|
||||
sb.append(String.valueOf(s.charAt(i)));
|
||||
sb.append(s.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user