Topic: Algorithms
The complexity of matrix multiplication of two matrices A and B whose orders are $m\times n$ and $n\times p$ respectively is
- A. $O(m\times p)$
- B. $O(m\times n^{2}\times p)$
- C. $O(m\times n\times p^{2})$
- D. $O(m\times n\times p)$
Answer: D. $O(m\times n\times p)$
Explanation: Matrix A is $m \times n$ and matrix B is $n \times p$. Multiplying them yields a matrix of order $m \times p$. Computing each of the $m \times p$ elements takes $O(n)$ time (multiplying a row by a column). Thus, the overall time complexity is $O(m \times n \times p)$.