ProgrammingModerate
Which statement about matrix multiplication in C is correct for an m x k matrix times a k x n matrix?
- A. The product is k x k regardless of m and n
- B. The product is m x k and needs only m x n multiplications
- C. The product is m x n and requires m x n x k multiplications with the naive method
- D. The product exists whenever m equals n
Correct answer: C. The product is m x n and requires m x n x k multiplications with the naive method
The inner dimension k is summed out, leaving m x n results, each needing k multiplications. So the naive method does m x n x k multiplications.
More C Programming questions
- Sum of a 2 x 2 window of m[i][j] = i + j starting at (1,1) in a 4 x 4 grid, i.e. m[1][1] + m[1][2] + m[2][1] + m[2][2]. What is the value?
- In a 2D array with int a[5][5], what is the total number of bytes in one row when int is 4 bytes?
- What is the most efficient way to check whether an n x n matrix is symmetric in O(n^2)?
- A 3 x 4 matrix holds a[i][j] = i 4 + j + 1. What is the sum of its boundary cells (first and last row, first and last column)?
- The number of ways to tile a 2 x 5 board exactly with 2 x 1 dominoes, counting orientations, is what?
- The length of the longest common subsequence of "ABCBDAB" and "BDCAB" is what?