-
Let A be a square matrix of size n × n. Consider the following pseudocode. What is the expected output?
c = 100;
for i = 1 to n do for j = 1 to n do
{
Temp = A [i] [j] + C;
A [i] [j] = A [j] [i];
A [j] [i] = Temp – C;
}
for i = 1 to n do
for j = 1 to n do
output (A [i] [j]);
-
- The matrix A itself
- Transpose of the matrix A
- Adding 100 to the upper diagonal elements and subtracting 100 from lower diagonal elements of A
- None of the above
- The matrix A itself
Correct Option: A
For the given pseudo code, each element of the upper triangle is interchanged by the corresponding element in lower triangle and later the lower triangular element is interchanged by the upper triangular once. Thus the final output matrix will be same as that of input matrix A.