Question: Coding in Java /** * * Given a square array, determines if it is diagonal * That is, returns true if all values in the

Coding in Java

/**

*

* Given a square array, determines if it is diagonal

* That is, returns true if all values in the array are 0

* except the main diagonal. The main diagonal is entries of the form

* data[i][j] where i == j. Elements on the main

* diagonal can be 0 or any other number.

*

* Examples:

* {{1,0,0},

* {0,2,0}

* {0,0,3}} yields true

*

* {{1,0,9},

* {0,2,0},

* {0,0,3}} yields false because 0,2 is nonzero

*

* {{0,0,0},

* {0,0,0},

* {0,0,3}} yields true because there can be 0

* entries on the diagonal if desired

* @param data input array

* @return true if it is diagonal, false otherwise

*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!