How do you easily measure the time complexity of an algorithm? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do you easily measure the time complexity of an algorithm?

Hey guys! I am trying to figure out if this code is correct and how can I measure the time complexity of it, please check, give me your feedback and answer my question: https://code.sololearn.com/cZE4E1iWG0Tb/#py P.D: I am studying that subject, please also help with a good page with information about and how can I measure it without going counting line per line with differents inputs. If you like the code, please upvote. Otherwise, tell me what can I improve.

31st May 2019, 6:10 AM
Rosana Rodrรญguez Milanรฉs
Rosana Rodrรญguez Milanรฉs - avatar
3 Answers
+ 3
Rosana Rodrรญguez Milanรฉs hi, ๐ŸŽ I'll give you the most basic information and assign one unit to every statement and at last summation of all statement units an basic complexity is calculated which is space complexity ๐ŸŽ if any loop is their in any statement then assign that loop with the number of times that loop is executing like if an loop is going to n time to run then you can assign them with n unit ๐ŸŽ then if their any nested loop then that inner loop with n unit and outer loop with n unit and if nested loop is their then assign n*n to the statement ๐ŸŽ if function are their then assign function with the statement that are present in that function if that has 5 statements then assign 5 to that function and the time that which the function is calling Have these ๐ŸŽ ๐ŸŽ ๐ŸŽ ๐ŸŽ ๐ŸŽ
31st May 2019, 6:28 AM
DishaAhuja
DishaAhuja - avatar
+ 4
๐ŸŽ complexity can be calculated in three notation like ๐ŸŽ BigOh(O) notation ๐ŸŽ Theta(ฮฆ) notation ๐ŸŽ omega(ฮ ) notation Every notation is calculated and defined according to worst case and the best case and average case complexity ๐ŸŽ this link will help about calculate complexity https://www.hackerearth.com/practice/basic-programming/complexity-analysis/time-and-space-complexity/tutorial/ ๐ŸŽ https://medium.com/@.RT/total-n00bs-guide-to-big-o-big-%CF%89-big-%CE%B8-aa259ae8a1c2
31st May 2019, 6:32 AM
DishaAhuja
DishaAhuja - avatar
+ 3
Here is an lesson about that which is quite good explanation https://www.sololearn.com/learn/6362/?ref=app If you have any further query ping me I'll loved to answer with some example https://www.sololearn.com/learn/6362/?ref=app Have these ๐ŸŽ ๐ŸŽ ๐ŸŽ ๐ŸŽ
31st May 2019, 6:34 AM
DishaAhuja
DishaAhuja - avatar