Reputation: 2407
The below are 3 algorithms for the same problem. How can one find the fastest algorithm?
I tried to divide both gradients by log and square root to find the steepest graph.
Upvotes: 0
Views: 102
Reputation: 178451
I am more comftorable giving guidelines after your comment - it proves you showed some effort.
You basically want to get to a formula t = f(n)
, and chose the one that grows slowest.
It can be done by using the information you have with some basic algebra, I will give an example for the rightest graph, and you will need to do the same for the others and get their function.
Rightest graph:
We know that for each increase of 1 in 2^n, there is increase of 4 in 2^t. From this:
2^t/2^n = 4 --> 2^t = 4*2^n --(log)--> log(2^t) = log(4*2^n) -->
--> t = log(4) + log(2^n) --> t = 2 + n
Use the same technique for the rest, and chose the one that is growing slowest, and you got your answer.
Good luck.
Upvotes: 1