Skip to interview prep
Apexed

How does Strassen's algorithm multiply matrices with 7 multiplications instead of 8, and what is its complexity?

HardDivide & conquer

Technical

Content review

Report an error

Not yet reviewed

Getting your answer ready…

Show model answer

Split each n × n matrix into four n/2 × n/2 blocks. The naive block method needs 8 block products, T(n) = 8T(n/2) + O(n²) = Θ(n³). Strassen forms 7 products of cleverly chosen sums and differences of blocks, then reconstructs the four result blocks with additions only: T(n) = 7T(n/2) + O(n²) = Θ(n^(log₂ 7)) ≈ Θ(n^2.807).

In practice it pays off only above a crossover size (often a few hundred), uses extra memory for temporaries, and is less numerically stable for floating point, so libraries switch to the classical method for small blocks. The demo multiplies 2 × 2 matrices with the seven products and prints how the multiplication count 7^k compares with 8^k for n = 2^k.

What interviewers listen for

  • 7 recursive products
  • Θ(n^2.807)
  • Large constants and stability trade-offs

Example program

How does Strassen's algorithm multiply matrices with 7 multiplications instead of 8, and what is its complexity — Data structures & algorithms interview questio