Java Program to Check Whether a Matrix is Symmetric or Not
A symmetric matrix is a square matrix in which the transpose of the square matrix is the same as the original square matrix. A square matrix is a matrix in which the number of columns is the same as the number of rows. If the matrix is a symmetric matrix then it is also a square matrix but vice versa isn’t true. Matrix is simply considered as 2D arrays for action to be performed. Here, we are going to see the approach to check if the entered square matrix is symmetric or not.
Input : 6 5 2 5 0 9 2 9 3 Output: The matrix is symmetric Input : 6 1 2 5 0 9 2 9 3 Output: The matrix is not symmetric
- Take the matrix as an input from the user
- Find transpose of the matrix
- Compare two matrices
- If the two matrices is the same then it is symmetric otherwise it’s not.
Output: Below both symmmericity and asymetricity is checked as follows:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.