style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -5,7 +5,7 @@ package com.thealgorithms.divideandconquer;
/*
* Binary Exponentiation is a method to calculate a to the power of b.
* It is used to calculate a^n in O(log n) time.
*
*
* Reference:
* https://iq.opengenus.org/binary-exponentiation/
*/

View File

@ -135,11 +135,7 @@ public final class ClosestPair {
* @param first (IN Parameter) first point <br>
* @param last (IN Parameter) last point <br>
*/
public void xQuickSort(
final Location[] a,
final int first,
final int last
) {
public void xQuickSort(final Location[] a, final int first, final int last) {
if (first < last) {
int q = xPartition(a, first, last); // pivot
xQuickSort(a, first, q - 1); // Left
@ -154,11 +150,7 @@ public final class ClosestPair {
* @param first (IN Parameter) first point <br>
* @param last (IN Parameter) last point <br>
*/
public void yQuickSort(
final Location[] a,
final int first,
final int last
) {
public void yQuickSort(final Location[] a, final int first, final int last) {
if (first < last) {
int q = yPartition(a, first, last); // pivot
yQuickSort(a, first, q - 1); // Left
@ -186,13 +178,7 @@ public final class ClosestPair {
// divide-left array
System.arraycopy(divideArray, 0, leftArray, 0, divideX);
// divide-right array
System.arraycopy(
divideArray,
divideX,
rightArray,
0,
indexNum - divideX
);
System.arraycopy(divideArray, divideX, rightArray, 0, indexNum - divideX);
double minLeftArea; // Minimum length of left array
double minRightArea; // Minimum length of right array

View File

@ -92,16 +92,10 @@ public class SkylineAlgorithm {
* @param right the skyline of the right part of points
* @return left the final skyline
*/
public ArrayList<Point> produceFinalSkyLine(
ArrayList<Point> left,
ArrayList<Point> right
) {
public ArrayList<Point> produceFinalSkyLine(ArrayList<Point> left, ArrayList<Point> right) {
// dominated points of ArrayList left are removed
for (int i = 0; i < left.size() - 1; i++) {
if (
left.get(i).x == left.get(i + 1).x &&
left.get(i).y > left.get(i + 1).y
) {
if (left.get(i).x == left.get(i + 1).x && left.get(i).y > left.get(i + 1).y) {
left.remove(i);
i--;
}
@ -172,10 +166,7 @@ public class SkylineAlgorithm {
*/
public boolean dominates(Point p1) {
// checks if p1 is dominated
return (
(this.x < p1.x && this.y <= p1.y) ||
(this.x <= p1.x && this.y < p1.y)
);
return ((this.x < p1.x && this.y <= p1.y) || (this.x <= p1.x && this.y < p1.y));
}
}

View File

@ -4,12 +4,12 @@ package com.thealgorithms.divideandconquer;
/*
* Uses the divide and conquer approach to multiply two matrices.
* Time Complexity: O(n^2.8074) better than the O(n^3) of the standard matrix multiplication algorithm.
* Space Complexity: O(n^2)
*
* This Matrix multiplication can be performed only on square matrices
* Time Complexity: O(n^2.8074) better than the O(n^3) of the standard matrix multiplication
* algorithm. Space Complexity: O(n^2)
*
* This Matrix multiplication can be performed only on square matrices
* where n is a power of 2. Order of both of the matrices are n × n.
*
*
* Reference:
* https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_algorithms_strassens_matrix_multiplication.htm#:~:text=Strassen's%20Matrix%20multiplication%20can%20be,matrices%20are%20n%20%C3%97%20n.
* https://www.geeksforgeeks.org/strassens-matrix-multiplication/
@ -139,5 +139,4 @@ public class StrassenMatrixMultiplication {
}
}
}
}