Skip to content

Conversation

@Rony-2004
Copy link

@Rony-2004 Rony-2004 commented Oct 26, 2025

Add MatrixDeterminant Algorithm

Description

This PR adds a new algorithm to calculate the determinant of a square matrix.
It supports any n × n matrix using recursion to compute minors.

Problem Statement

  • Implement a function to calculate the determinant of a square matrix.
  • Only square matrices are allowed; throw an exception or handle error for non-square matrices.
  • Return 0 if the matrix is singular (determinant = 0).

Example

double[][] matrix1 = {{1,2},{3,4}};
determinant(matrix1); // returns -2

double[][] matrix2 = {{2,0,1},{3,0,0},{5,1,1}};
determinant(matrix2); // returns 3

Implement a function to calculate the determinant of a square matrix, handling singular matrices and non-square matrices.
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.11%. Comparing base (2da0465) to head (f5405e8).

Files with missing lines Patch % Lines
...va/com/thealgorithms/matrix/MatrixDeterminant.java 0.00% 24 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6948      +/-   ##
============================================
- Coverage     78.20%   78.11%   -0.09%     
  Complexity     6563     6563              
============================================
  Files           743      744       +1     
  Lines         21886    21910      +24     
  Branches       4284     4291       +7     
============================================
  Hits          17115    17115              
- Misses         4087     4111      +24     
  Partials        684      684              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rony-2004 Rony-2004 closed this Oct 26, 2025
@Rony-2004 Rony-2004 deleted the patch-1 branch October 26, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants