Refactor files to be in correctly nested packages (#6120)

This commit is contained in:
varada610
2025-01-10 23:17:40 -08:00
committed by GitHub
parent a9633c0000
commit 1e6ed97fcf
13 changed files with 75 additions and 77 deletions

View File

@ -55,7 +55,6 @@ com.thealgorithms.maths.SumOfArithmeticSeries=UselessParentheses
com.thealgorithms.maths.TrinomialTriangle=UselessParentheses com.thealgorithms.maths.TrinomialTriangle=UselessParentheses
com.thealgorithms.maths.VampireNumber=CollapsibleIfStatements com.thealgorithms.maths.VampireNumber=CollapsibleIfStatements
com.thealgorithms.maths.Volume=UselessParentheses com.thealgorithms.maths.Volume=UselessParentheses
com.thealgorithms.matrixexponentiation.Fibonacci=UnnecessaryFullyQualifiedName
com.thealgorithms.misc.Sparsity=UselessParentheses com.thealgorithms.misc.Sparsity=UselessParentheses
com.thealgorithms.misc.ThreeSumProblem=UselessParentheses com.thealgorithms.misc.ThreeSumProblem=UselessParentheses
com.thealgorithms.misc.WordBoggle=UselessParentheses com.thealgorithms.misc.WordBoggle=UselessParentheses

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
/** /**
* This class provides methods to compute the inverse of a square matrix * This class provides methods to compute the inverse of a square matrix

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
/** /**
* *

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
// Problem Statement // Problem Statement
/* /*

View File

@ -1,62 +1,62 @@
package com.thealgorithms.others; package com.thealgorithms.matrix;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PrintAMatrixInSpiralOrder { public class PrintAMatrixInSpiralOrder {
/** /**
* Search a key in row and column wise sorted matrix * Search a key in row and column wise sorted matrix
* *
* @param matrix matrix to be searched * @param matrix matrix to be searched
* @param row number of rows matrix has * @param row number of rows matrix has
* @param col number of columns matrix has * @param col number of columns matrix has
* @author Sadiul Hakim : https://github.com/sadiul-hakim * @author Sadiul Hakim : https://github.com/sadiul-hakim
*/ */
public List<Integer> print(int[][] matrix, int row, int col) { public List<Integer> print(int[][] matrix, int row, int col) {
// r traverses matrix row wise from first // r traverses matrix row wise from first
int r = 0; int r = 0;
// c traverses matrix column wise from first // c traverses matrix column wise from first
int c = 0; int c = 0;
int i; int i;
List<Integer> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
while (r < row && c < col) { while (r < row && c < col) {
// print first row of matrix // print first row of matrix
for (i = c; i < col; i++) { for (i = c; i < col; i++) {
result.add(matrix[r][i]); result.add(matrix[r][i]);
} }
// increase r by one because first row printed // increase r by one because first row printed
r++; r++;
// print last column // print last column
for (i = r; i < row; i++) { for (i = r; i < row; i++) {
result.add(matrix[i][col - 1]); result.add(matrix[i][col - 1]);
} }
// decrease col by one because last column has been printed // decrease col by one because last column has been printed
col--; col--;
// print rows from last except printed elements // print rows from last except printed elements
if (r < row) { if (r < row) {
for (i = col - 1; i >= c; i--) { for (i = col - 1; i >= c; i--) {
result.add(matrix[row - 1][i]); result.add(matrix[row - 1][i]);
} }
row--; row--;
} }
// print columns from first except printed elements // print columns from first except printed elements
if (c < col) { if (c < col) {
for (i = row - 1; i >= r; i--) { for (i = row - 1; i >= r; i--) {
result.add(matrix[i][c]); result.add(matrix[i][c]);
} }
c++; c++;
} }
} }
return result; return result;
} }
} }

View File

@ -1,4 +1,4 @@
package com.thealgorithms.others; package com.thealgorithms.matrix;
import java.util.Scanner; import java.util.Scanner;
/** /**

View File

@ -1,4 +1,4 @@
package com.thealgorithms.matrixexponentiation; package com.thealgorithms.matrix.matrixexponentiation;
import java.util.Scanner; import java.util.Scanner;
@ -55,14 +55,14 @@ public final class Fibonacci {
*/ */
public static int[][] fib(int n) { public static int[][] fib(int n) {
if (n == 0) { if (n == 0) {
return Fibonacci.IDENTITY_MATRIX; return IDENTITY_MATRIX;
} else { } else {
int[][] cachedResult = fib(n / 2); int[][] cachedResult = fib(n / 2);
int[][] matrixExpResult = matrixMultiplication(cachedResult, cachedResult); int[][] matrixExpResult = matrixMultiplication(cachedResult, cachedResult);
if (n % 2 == 0) { if (n % 2 == 0) {
return matrixExpResult; return matrixExpResult;
} else { } else {
return matrixMultiplication(Fibonacci.FIB_MATRIX, matrixExpResult); return matrixMultiplication(FIB_MATRIX, matrixExpResult);
} }
} }
} }

View File

@ -1,5 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.util.stream.Stream; import java.util.stream.Stream;

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@ -1,4 +1,4 @@
package com.thealgorithms.misc; package com.thealgorithms.matrix;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;

View File

@ -1,4 +1,4 @@
package com.thealgorithms.others; package com.thealgorithms.matrix;
import static org.junit.jupiter.api.Assertions.assertIterableEquals; import static org.junit.jupiter.api.Assertions.assertIterableEquals;