Strassen’s Algorithm is an algorithm for matrix multiplication. It is faster than the naive matrix multiplication algorithm. In order to know how, let’s compare both of these algorithms along with the their implementation in C++.

Suppose we are multiplying 2 matrices A and B and both of them have dimensions n x n. The resulting matrix C after multiplication in the naive algorithm is obtained by the formula:

Image for post
Image for post

for i = 1, …, n and j = 1, …, n

The C++ implementation of this formula is:

int** multiply(int** A, int** B, int n) { int** C = initializeMatrix(n); setToZero(C…

Saahil Mahato

Hi, I am a Computer Science undergrad. I enjoy programming and anything to do with technology in general. I write about things that I am curious about.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store