What is the time complexity for the following code What is t
What is the time complexity for the following code:
What is the time complexity for the following code: for (int i = 1 to n) {for (int j = j to n) {for (int k = j to n) {Sum += A[i]*b[j]*c[k]} If (gcd(I, j) ==1){j = n}}}Solution
The Time complexity of nested loops is nothing but the number of times the innermost statements are executed.
Here we have 3 for loops and every for loop will be executed n times. Therefore the total time complexity of given
nested loops is equal to O(n^3).
