Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -1,8 +1,8 @@
package com.thealgorithms.searches;
import com.thealgorithms.devutils.searches.SearchAlgorithm;
import java.util.Random;
import java.util.stream.Stream;
import com.thealgorithms.devutils.searches.SearchAlgorithm;
/**
* Linear search is the easiest search algorithm It works with sorted and
@ -42,8 +42,10 @@ public class LinearSearch implements SearchAlgorithm {
Random r = new Random();
int size = 200;
int maxElement = 100;
Integer[] integers
= Stream.generate(() -> r.nextInt(maxElement)).limit(size).toArray(Integer[]::new);
Integer[] integers = Stream
.generate(() -> r.nextInt(maxElement))
.limit(size)
.toArray(Integer[]::new);
// the element that should be found
Integer shouldBeFound = integers[r.nextInt(size - 1)];
@ -52,8 +54,13 @@ public class LinearSearch implements SearchAlgorithm {
int atIndex = search.find(integers, shouldBeFound);
System.out.println(
String.format(
"Should be found: %d. Found %d at index %d. An array length %d",
shouldBeFound, integers[atIndex], atIndex, size));
String.format(
"Should be found: %d. Found %d at index %d. An array length %d",
shouldBeFound,
integers[atIndex],
atIndex,
size
)
);
}
}