0

How do i get the value of the increment here in time complexity? Assuming my value is n=6.

ctrl=1 while (ctrl<=n-2) { For (k=1; k<=n; k++) printf("%d, %d, ctrl, k) ctrl =ctrl +1 }

23rd Oct 2020, 5:45 AM
Khryss Patrick Estrada
Khryss Patrick Estrada - avatar
1 Resposta
+ 3
It's linear. The time increase is directly correlated to the size of n. As n increases/decreases so the the time the loop takes to run. Therefore it is O(n). https://www.sololearn.com/learn/6362/?ref=app
23rd Oct 2020, 6:10 AM
ChaoticDawg
ChaoticDawg - avatar