Algorithms | Analysis of Algorithms | Question 18

Last Updated :
Discuss
Comments

Consider the following function,

 int unknown(int n) {
    int i, j, k = 0;
    for (i  = n/2; i <= n; i++)
        for (j = 2; j <= n; j = j * 2)
            k = k + n/2;
    return k;
 }

What is the time complexity of the function? (GATE CS 2013)

n^2

n logn

n^3

n^3 logn 

Share your thoughts in the comments