Algorithm and Flowchart to Find transpose of a matrix

(4662 Views)


Algorithm to find transpose of a matrix

Transpose of a matrix is obtained by changing rows to columns and columns to rows.

Flowchart to find transpose of a matrix

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 b[i][j] = a[j][i] j=j+1 // Increment j by 1 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,

  1. We first declare two matrices a and b of order mxn
  2. Then we read matrix a from the user. We will use matrix b to store transpose of the matrix.
  3. Now, we declare two variables i, j and intialize them to 0
  4. After this we start a loop of i, till it reaches n which gave us the column indexes and insude 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[1][2]=a[2][1], thus assigning the matrix b to the transpose of a.

Solution Worked 5 UpvotesUpvote

        

Solution Didn't Worked 1 DownvotesDownvote



Comments



Search

Play 2048 Game Online

Play Duckhunt Online

Need Help?

Looking for any Software or Tutorial?
Don't Worry, we will find it for you
Contact Now

Search Tags

    Pseudocode for transpose of a matrix