Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

order of growth in algorithms

Suppose that you time a program as a function of N and produce the following table.

        N   seconds
-------------------
    19683      0.00
    59049      0.00
   177147      0.01
   531441      0.08
  1594323      0.44
  4782969      2.46
 14348907     13.58
 43046721     74.99
129140163    414.20
387420489   2287.85

Estimate the order of growth of the running time as a function of N. Assume that the running time obeys a power law T(N) ~ a N^b. For your answer, enter the constant b. Your answer will be marked as correct if it is within 1% of the target answer - we recommend using two digits after the decimal separator, e.g., 2.34.

Can someone explain how to calculate this?

like image 713
Akosha Avatar asked Jan 31 '26 10:01

Akosha


1 Answers

Well, it is a simple mathematical problem.

I : a*387420489^b = 2287.85 -> a = 387420489^b/2287.85
II: a*43046721^b  =  74.99  -> a = 43046721^b/74.99
III: (I and II)-> 387420489^b/2287.85 = 43046721^b/74.99 ->
-> http://www.purplemath.com/modules/solvexpo2.htm

Use logarithms to solve.

like image 120
user1021852 Avatar answered Feb 03 '26 06:02

user1021852