Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 1
Plz Explain The TimeComplexity Of Following Code In Detail
3 Respostas
+ 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
0
ops....Sorry.....Mouli š®š³ and Avinesh ...