How do you easily measure the time complexity of an algorithm? | Sololearn: Learn to code for FREE!


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: 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.

5/31/2019 6:10:46 AM

Rosana Rodríguez Milanés

3 Answers

New Answer


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 🍎 🍎 🍎 🍎 🍎


🍎 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 🍎


Here is an lesson about that which is quite good explanation If you have any further query ping me I'll loved to answer with some example Have these 🍎 🍎 🍎 🍎