Find the minor (secondary) diagonal of a matrix.

Posted on 28-04-2013 23:28 by graham
This short tutorial shows how to find elements of a minor (secondary) diagonal of a matrix.

What is a minor diagonal

Minor diagonal is the collection of elements of a matrix that go from it top right corner to the in the bottom-left direction. So, it is a collection of elements Aij, where i = number of columns - j.

Java code to find the minor diagonal

Let's say we have a matrix in a two-dimensional table Integer[n][m]. Then, to find the minor diagonal, we follow the algorithm below:
// the matrix
Integer[][] = new Integer[m][n];

for (i = 0; 0 < n; i++)
for (j = 0; j < m; j++)
if (i == (m - j - 1))
// element i,j lies on the diagonal
// element i,j does not lie on the diagonal

Javascript code

To see the above algorithm in action in Javascript, visit our minor diagonal sandbox script.
text excellent - very good 2
como reconquistar
Added on 24-01-2014 04:01 by anonymous
thanks a lot! You're great!
Added on 12-03-2014 02:43 by anonymous


Add comment

Has this tutorial been helpful to you? Or do you see anything wrong? We appreciate your opinion!
Your comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems