![]() |
VOOZH | about |
The determinant of a matrix is a special calculated value that can only be calculated if the matrix has same number of rows and columns (square matrix). It is helpful in determining the system of linear equations, image processing, and determining whether the matrix is singular or non-singular.
In this article, we are going to learn the step-by-step procedure to calculate the determinant of a matrix and Java implementations using both recursive and non-recursive approaches.
Examples:
Determinant of 2*2 matrix:
[4, 3]
[2, 3]
= (4*3)-(3*2)
= 12-6
= 6
Determinant of 3*3 matrix:
[1, 3, -2]
[-1, 2, 1]
[1, 0, -2]
= 1(-4-0)-3(2-1)+(-2)(0-2)
= -4-3+4
= -3
Note:
Let's see an example to get a clear concept of the above topic.
Example 1: Finding the determinant of a matrix using recursion.
Determinant of the matrix is: 6
Time complexity: O(n3)
Example 2:Non-recursive Implementation of finding determinant of a matrix.
Determinant of the matrix is: 30
Time complexity: O(n3)