알고리즘
[Introduction to Algorithms, CLRS] Exercise 1.2-3
nevermet
2017. 8. 15. 12:31
This is a solution for Introduction to Algorithms. I write this for my study purpose.
1.2-3
What is the smallest value of n such that an algorithm whose running time is 100n2 runs faster than an algorithm whose running time is 2n on the same machine?
Answer:
A (quadratic time complexity) will run much faster than B (exponential time complexity) for very large values of n. Let’s start checking from n=1 and go up for values of n which are power of 2.
Somewhere between 8 and 16, A starts to run faster than B. Let’s do what we were doing but now we are going to try middle value of the range, repeatedly (binary search).
So, at , A starts to run faster than B.
source: https://atekihcan.github.io/CLRS/E01.02-03/