To help you better understand why the definition of Big-O is concerned only with the behavior of functions for large values ofn, choose two functions with different growth rates in which the faster growing function is lower at small values ofn, but eventually becomes larger. Write a short program that periodically compares the values of the two functions and illustrates the point at which the faster growing function overtakes the slower growing one. As an example, consider the following two functions:
Shown below is a table of the values of both functions for small values ofn.
n f(n) g(n)10 51150 200020 201300 1600030 451450 5400040 801600 12800050 1251750 25000060 1801900 43200070 2452050 68600080 3202200 102400090 4052350 1458000100 5002500 2000000110 6052650 2662000120 7202800 3456000130 8452950 4394000140 9803100 5488000150 11253250 6750000160 12803400 8192000170 14453550 9826000180 16203700 11664000190 18053850 13718000200 20004000 16000000210 22054150 18522000220 24204300 21296000230 26454450 24334000240 28804600 27648000250 31254750 31250000260 33804900 35152000
Oncenreaches 260govertakesf.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here