+ 1

Plz Explain The TimeComplexity Of Following Code In Detail

https://code.sololearn.com/cKUT4VHoV1UL/?ref=app

17th Sep 2020, 3:36 PM
RAJ PATIL
RAJ PATIL - avatar
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.
17th Sep 2020, 4:18 PM
Avinesh
Avinesh - avatar
0
Avinesh But i don't understand Why Not n^2 + n^2 = n^4
17th Sep 2020, 4:25 PM
RAJ PATIL
RAJ PATIL - avatar
0
ops....Sorry.....Mouli 🇮🇳 and Avinesh ...
17th Sep 2020, 4:39 PM
RAJ PATIL
RAJ PATIL - avatar