ISRO Scientist/Engineer CSE 2023Digital Logic › Not yet assigned to a topic
ISRO Scientist/Engineer CSE 2023 PYQ: The complexity of matrix multiplication of two matrices A and B whose orders are $\mathrm{m} \times…
The complexity of matrix multiplication of two matrices A and B whose orders are $\mathrm{m} \times \mathrm{n}$ and $\mathrm{n} \times \mathrm{p}$ respectively is
- A$\mathrm{O}(\mathrm{m} \times \mathrm{p})$
- B$O\left(m \times n^{2} \times p\right)$
- C$\mathrm{O}\left(\mathrm{m} \times \mathrm{n} \times \mathrm{p}^{2}\right)$
- D$\mathrm{O}(\mathrm{m} \times \mathrm{n} \times \mathrm{p})$Correct answer
Answer
(D) $\mathrm{O}(\mathrm{m} \times \mathrm{n} \times \mathrm{p})$
Approach
Matrix multiplication of an m×n matrix A and an n×p matrix B produces an m×p matrix C. Each entry C[i][j] is the dot product of row i of A (length n) and column j of B (length n), requiring n multiplications and n-1 additions. Summing over all m×p entries gives the total operation count.
Reviewed by ISRO IQ Editorial Team.