How to calculate the growth rate, and time amount of an algorithm?
<p>I am currently enjoying <em>Think Complexity</em> by Allen Downey and a few hours ago I finished the section on growth rate. I paused reading and googled growth rates, and expanded on the info the book gave me. I also found out that you can calculate the amount of <em>time</em> it takes for an algorithm to calculate the raw data. I have a lot of questions that can't be answered by google, or maybe I need a personal touch in my answers since it really helps me understand. My questions are:</p>

<p><strong>1-</strong> How is it possible to calculate the growth rate of a simple algorithm? For example, I just wrote this loop to calculate sine of a given angle in radians using Tayler series:</p>

<pre><code>    for i in range(0, 360):
        return sum(((-1)**i / (factorial((2 * i) + 1))) * d ** ((2*i) + 1))
</code></pre>

<p>And factorial:</p>

<pre><code>def factorial(n):
    factorial = 1
    for i in range(1, n+1):
        factorial *= i

return factorial
</code></pre>

<p>How do I calculate its growth rate?</p>

<p><strong>2-</strong> I became familiar with some very bad algorithms like Bogosort. It takes a large amount of time to sort an array using bogosort. But how do you calculate the time? It differs from computer to computer.</p>

<p><strong>3-</strong> What is the Big-O notation and how is it related to the growth rate?</p>

<p>Thanks for your answers.</p>