-
[Introduction to Algorithms, CLRS] Exercise 1.2-3알고리즘 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/
'알고리즘' 카테고리의 다른 글
[Introduction to Algorithms, CLRS] Exercises 2.1-1 (0) 2017.08.28 [Introduction to Algorithms, CLRS] Problems 1.1 (0) 2017.08.26 [Introduction to Algorithms, CLRS] Exercise 1.2-2 (0) 2017.08.15 [Introduction to Algorithms, CLRS] Exercise 1.2-1 (0) 2017.08.15 [Introduction to Algorithms, CLRS] Exercise 1.1-5 (0) 2017.08.15