![]() |
VOOZH | about |
Given an M * N matrix, the task is to find the Frobenius Norm of the matrix. The Frobenius Norm of a matrix is defined as the square root of the sum of the squares of the elements of the matrix.
Example:
Input: mat[][] = {{1, 2}, {3, 4}}
Output: 5.47723
sqrt(12 + 22 + 32 + 42) = sqrt(30) = 5.47723
Input: mat[][] = {{1, 4, 6}, {7, 9, 10}}
Output: 16.8226
Approach: Find the sum of squares of the elements of the matrix and then print the square root of the calculated value.
Below is the implementation of the above approach:
5.47723
Time Complexity: O(M*N)
Auxiliary Space: O(1)