01
Overview

Transpose and symmetry.

Swap rows with columns to flip a matrix across its main diagonal — and use the same idea to check for symmetry.

The transpose of a matrix swaps its rows and columns: element m[r][c] becomes element t[c][r]. Geometrically, it reflects the matrix across the main diagonal.

A matrix is symmetric if it equals its own transpose — that is, m[r][c] == m[c][r] for every r and c. This is a square-matrix concept.

02
Core Concept

Swap indices when reading or writing.

Transpose flips; symmetry checks the flip is a no-op.

Transpose (works for rectangular matrices)

public static int[][] transpose(int[][] m) {
    int rows = m.length;
    int cols = m[0].length;
    int[][] t = new int[cols][rows];
    for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {
            t[c][r] = m[r][c];
        }
    }
    return t;
}

Notice the result has dimensions cols × rows — the original's columns become the new array's rows.

Symmetric check (square matrices only)

public static boolean isSymmetric(int[][] m) {
    int n = m.length;
    for (int r = 0; r < n; r++) {
        for (int c = r + 1; c < n; c++) {
            if (m[r][c] != m[c][r]) return false;
        }
    }
    return true;
}

Only the upper triangle (above the main diagonal) needs to be checked; the lower triangle would just check the same pairs again.

Edge case: rectangular matrices

Symmetry only makes sense for square matrices. If the matrix is rectangular, return false right away.

03
Key Vocabulary

Transpose vocabulary.

Standard matrix terminology.

Vocabulary
  • Transpose — matrix with rows and columns swapped.
  • Symmetric matrix — equals its own transpose.
  • Main diagonal — cells where r == c; unaffected by transpose.
  • Upper triangle — cells where r < c.
  • Lower triangle — cells where r > c.
  • Square matrix — same number of rows and columns.
04
AP Exam Focus

How transpose and symmetry are tested.

Result-grid dimensions and the upper-triangle trick are common.

Exam Focus
  • Transpose dimensions. new int[cols][rows] for an rows × cols input.
  • Symmetry restricted to square. Rectangular matrices can never be symmetric.
  • Upper triangle only. Saves half the comparisons.
  • Index swap. Write t[c][r] = m[r][c], not t[r][c].
05
Worked Example

Transpose a 2x3 matrix.

Verify dimensions and contents.

Worked Example AP-style reasoning

Problem. Transpose:

{{1, 2, 3},
 {4, 5, 6}}

Step 1. Input is 2 rows × 3 columns. Result is 3 rows × 2 columns.

Step 2. Apply t[c][r] = m[r][c] for each cell:

  • m[0][0] = 1 → t[0][0] = 1
  • m[0][1] = 2 → t[1][0] = 2
  • m[0][2] = 3 → t[2][0] = 3
  • m[1][0] = 4 → t[0][1] = 4
  • m[1][1] = 5 → t[1][1] = 5
  • m[1][2] = 6 → t[2][1] = 6

Result.

{{1, 4},
 {2, 5},
 {3, 6}}

Symmetry check. If the input were {1, 2}, {2, 5}, it equals its own transpose {1, 2}, {2, 5} → symmetric. If it were {1, 2}, {3, 5}, m[0][1] = 2 but m[1][0] = 3 → not symmetric.

06
Common Mistakes

Transpose and symmetry errors.

Index swaps and dimension confusion are the top traps.

Watch Out
  • Wrong result size. Result is cols × rows, not rows × cols.
  • Writing t[r][c] instead of t[c][r].
  • Trying to transpose in place on rectangular grids. Impossible without resizing.
  • Symmetry checks on rectangular inputs. Always check that the matrix is square first.
  • Lower triangle redundancy. Checking both triangles doubles the work.
07
Reference Table

Transpose and symmetry summary.

The index relationships.

Transpose Reference

AP Quick Reference
Operation Index relationship AP Exam Tip
Transpose write t[c][r] = m[r][c] Swap c and r.
Transpose dimensions cols × rows Result shape flips.
Symmetry condition m[r][c] == m[c][r] True for all pairs.
Symmetry scan range c > r Upper triangle only.
Rectangular input Never symmetric Check shape first.
08
Practice Tip

How to master transpose and symmetry.

Index swap is the only trick — practise until it's reflex.

Practice Strategy

Use the three practice tools below this lesson in order:

  • MCQ Practice — for transpose questions, draw the result grid with swapped dimensions and fill it cell by cell.
  • Java Lab — implement transpose for rectangular grids and isSymmetric for squares. Test on identity, zero, and known-symmetric matrices.
  • FRQ Practice — when a problem hints at reflecting or swapping, reach for the transpose index swap as the core operation.
09
Section · 09

Practice — attempt these now.

AP-style assessments aligned to this lesson. Time them.

Topic Quiz 40 min 40 marks Pending

AP CSA Topic Practice: Transpose and Symmetry

AP-style topic practice assessment

Start
FRQ Practice 30 min 18 marks Pending

AP CSA Unit 05 Topic 15 Transpose and Symmetry FRQ Practice

AP-style topic practice assessment

Start