Time Complexity(O(n)) of this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Time Complexity(O(n)) of this code

In order to know the algorithm efficiency of a code we use the (O(n)) function, better known as Time Complexity. What would the Time Complexity(O(n)) of this code be? https://code.sololearn.com/cCE49j2rbO9s/?ref=app

18th Apr 2020, 3:40 PM
petenera_
petenera_ - avatar
2 Answers
+ 2
Its O(n^2) , as your code uses nested loops. Basically time complexcity is measured by big 'Oh' notation or O() function . O(n)-this represent a linear time complexcity.that means the time interval for execution of your code increases linearly with input provided. O(n^2)- this represent a time complexcity that varies as a quadratic function of input provided.
19th Apr 2020, 2:36 AM
kanishkaditya shukla
kanishkaditya shukla - avatar
0
kanishkaditya shukla Thank you for the explanation, I understand it much better now
19th Apr 2020, 9:17 AM
petenera_
petenera_ - avatar