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.
3 Respuestas
+ 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 🍎 🍎 🍎 🍎 🍎
+ 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
+ 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 🍎 🍎 🍎 🍎