How to calcualte the Big-O complexity of the following algorithm?
for(i=1;i&lt;=n;i++)
{
    for(j=1 ; j &lt;= i*i ; j++)
    {
        for(k=1 ; k&lt;= n/2 ; k++) 
        {
        x = y + z;
        }
     }
}


The triple-nested loop is equivalent to the summation
$$\sum_{i=1}^{n}\sum_{j=1}^{i^2} \sum_{k=1}^{n/2} 1$$
$$=\frac{n}{2}(\sum_{i=1}^{n}\sum_{j=1}^{i^2}1)$$
$$=\frac{n}{2}(\sum_{i=1}^{n}i^2)$$
$$=\frac{n}{2} \cdot (\frac{1}{6}n(n+1)(2n+1))$$
$$=O(n^4)$$

In terms of actual code efficiency, since x=y+z is invariant in the loop, any good optimizing compiler will extract the statement out of the loop (in compiler-speak, hoist the statement to loop preheader), hence making the compiled code run in $O(1)$.