+ 1
Plz Explain The TimeComplexity Of Following Code In Detail
3 Respuestas
+ 2
Considering that you have 2 sets of for loops and each with a nested for as well.
1st loop -> n×n×c = c×(n^2)
where 'c' is constant time for if else.
2nd loop -> n×n×c = c×(n^2)
where 'c' is constant time for assignment operation.
Now neglecting the constant terms you have (n^2)+(n^2) = 2(n^2).
Again neglecting the constant 2, the time complexity should be O(n^2).
I have answered this with my basic understanding. I could be completely wrong, if so then kindly ignore it.
0
Avinesh But i don't understand Why Not n^2 + n^2 = n^4