DATA STRUCTURE
Programming and Technical
Logical Reasoning
Decision Making and Problem Solving
Vrinda writes an efficient program to sum two square diagonal matrices
(matrices with elements only on diagonal). The size of each matrix is nXn. What is the
time complexity of Vrinda's algorithm?
Read Solution (Total 6)
-
- We know a square matrix can be a diagonal matrix.The number of diagonal elements in Square matrix of size n*n is n.
Diagonal matrix : A matrix having non zero elements diagonally.
therefore time complexity is O(n). - 7 years agoHelpfull: Yes(4) No(0)
- O(n^2) because to access 2-d array we have to run to for loops thus adding to nXn matrices will take O(n^2)
- 6 years agoHelpfull: Yes(2) No(0)
- O(n^3) For each row, (n*n) operations take place. For n rows, n*n*n = n^3
- 7 years agoHelpfull: Yes(0) No(3)
- O(n)-time complexiity
- 6 years agoHelpfull: Yes(0) No(0)
- The complexity will be O(n).
- 6 years agoHelpfull: Yes(0) No(0)
- Ans: &theta(n)
- 6 years agoHelpfull: Yes(0) No(0)
DATA STRUCTURE Other Question