Skip to content

Refactoring the files to be in correctly nested packages #6120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.misc;
package com.thealgorithms.matrix;

/**
* This class provides methods to compute the inverse of a square matrix
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.misc;
package com.thealgorithms.matrix;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.misc;
package com.thealgorithms.matrix;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.misc;
package com.thealgorithms.matrix;

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

import java.util.ArrayList;
import java.util.List;

public class PrintAMatrixInSpiralOrder {
/**
* Search a key in row and column wise sorted matrix
*
* @param matrix matrix to be searched
* @param row number of rows matrix has
* @param col number of columns matrix has
* @author Sadiul Hakim : https://github.com/sadiul-hakim
*/

public List<Integer> print(int[][] matrix, int row, int col) {

// r traverses matrix row wise from first
int r = 0;
// c traverses matrix column wise from first
int c = 0;
int i;

List<Integer> result = new ArrayList<>();

while (r < row && c < col) {
// print first row of matrix
for (i = c; i < col; i++) {
result.add(matrix[r][i]);
}

// increase r by one because first row printed
r++;

// print last column
for (i = r; i < row; i++) {
result.add(matrix[i][col - 1]);
}

// decrease col by one because last column has been printed
col--;

// print rows from last except printed elements
if (r < row) {
for (i = col - 1; i >= c; i--) {
result.add(matrix[row - 1][i]);
}

row--;
}

// print columns from first except printed elements
if (c < col) {
for (i = row - 1; i >= r; i--) {
result.add(matrix[i][c]);
}
c++;
}
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.others;
package com.thealgorithms.matrix;

import java.util.Scanner;
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.matrixexponentiation;
package com.thealgorithms.matrix.matrixexponentiation;

import java.util.Scanner;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.thealgorithms.misc;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
package com.thealgorithms.matrix;

import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.misc;
package com.thealgorithms.matrix;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.assertNull;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.thealgorithms.others;
package com.thealgorithms.matrix;

import static org.junit.jupiter.api.Assertions.assertIterableEquals;

Expand Down
Loading