[Solved] Java boolean isSymmetric [closed]


You should just Google this stuff. There were plenty of answers out there.

But all you have to do is check if (a,b) is the same as (b,a).

public static boolean isSymetric(int[][] array){
    for(int a = 0; a < array.length; a++){ 
        for(int b = 0; b < array.length; b++){
            if(array[a][b]!=array[b][a]){
                return false;
            }
        }
    }
    return true;
}

In this method the outer most for loop goes through the rows and the inner for loop is going through the columns.

You just have to go through each and every element in the matrix.
If array[a][b] == array[b][a] then you can check the next one. If they are not the same then this matrix is not symmetric.

3

solved Java boolean isSymmetric [closed]