Runtime analysis of a nested loop I have some difficulties performing the worst case analysis on this algorithm.
The outermost loop is executed $2N$ times.
The while loop, in the worst case, will increase by $2$ each time, so it performs $i/2$ basic operations ($*2$ because double call)

for (i=1; i&lt;=2*N; i++) {
        j = 0;
        while (j &lt;= i) {
            a[i] = function (function (a[i]));
            if (c[i][j] != 0)
                j = j + 6;
            else
                j = j + 2;
        }
    }


function is the basic operation.
Am I going the right way?
The worst case for the number of function calls is (as you already observed)

$$\sum_{i=1}^{2N}\sum_{j=1}^{i/2} 2 =\sum_{i=1}^{2N} i = \frac{2N(2N+1)}{2}=2N^2+N,$$ 

by Gauß' summation formula.