Transpose of a matrix is obtained by changing rows to columns and columns to rows. It is denoted by AT
Flowchart to find transpose of a matrix
Pseudocode to find transpose of a matrix
Step 1: Start
Step 2: Declare matrix a[m][n] of order mxn
Step 3: Read matrix a[m][n] from User
Step 4: Declare matrix b[m][n] of order mxn
Step 5: // Transposing the Matrix
5.1: Declare variables i, j
5.2: Set i=0, j=0
5.3: Repeat until i < n
5.3.1: Repeat until j < m
220.127.116.11: b[i][j] = a[j][i]
18.104.22.168: j=j+1 // Increment j by 1
5.3.2: i=i+1 // Increment i by 1
5.4: Print matrix b
// The matrix b is the transpose of a and can be printed now
Step 6: Stop
In the above algorithm,
- We first declare two matrices a and b of order mxn
- Then we read matrix a from the user. We will use matrix b to store transpose of the matrix.
- Now, we declare two variables i, j and initialize them to 0
- After this we start a loop of i, till it reaches n which gave us the column indexes and inside it a loop of j which gives us the elements of the row.
The statement b[i][j] = a[j][i] gives the value of a by changing the row to column and column to row and stores in b. for e.g. i=1, j=2 then b=a, thus assigning the matrix b to the transpose of a.