Identifying Runtime Complexity
Runtime complexity is a term that we use to describe how performance an algorithm is.
We use runtime complexity to compare different solutions to a given problem or different algorithms.
Our goal is to make sure that we have the ability to identifty a given runtime complexity.
How much more processing power/time is require to run your algorithm if we double the inputs?
Some tips right here (in the next image) on some common complexities and how yo can identifiy them:
Big ‘O’ Notation is another way of referencing runtime complexity.
What is the runtime complexity of your solution?
What is the big O of your solution?
They are both asking what is the efficiency of your solution?
In this repository we can see that each problem has several solutions:
Examples of quadratic runtime or N^2.
Two nested for loops iterating over the same collection
In case of two nested for loops iterating over different collections we are talking about O(n*m) nor O(n²).
In the Fibonacci exercise there are 2 solutions. The first is an iterative solution, therefore it is an example of Linear Time: O(n).
The second solution is recursive, a clear example of Exponential Time: O(2^n)
Yes. In the recursive solution, if instead of calculating the result for the value 5 we do it for 6, the number of times the fib(n) function is called grows exponentially.
On the other hand, if you look at the test results, the time used to solve the Fibonacci series of a large number with the recursive function is much higher than if we use the iterative function