recategorized by
4,196 views
1 votes
1 votes
int A(int n){
    for(i = 1; i < n; i++)
        for(j = 1; j < i; j *= 2)
            for(k = j; k >= 1; k /= 2)
                if(n = 0) return 1;
                else{
                    for(z = 0; z < n; z++){
                    // do something
                    }
                }
}

 

How do find the complexity of this problem?

The answer is supposed to be O(n log log n), but it maybe wrong.

recategorized by

1 Answer

0 votes
0 votes

I am getting O(nloglogn) .

Since the k loop is running loglogn times. Everytime k loop is executed , the z loop runs n times. Hence O(nloglogn)

 

Related questions

0 votes
0 votes
0 answers
1
Akriti sood asked Dec 27, 2016
368 views
in an effort to make MERGE-SORT faster, you decide to divide the array into k equal sized, disjoint subarrays, where k 2. This means that you have to merge k lists. How ...
2 votes
2 votes
1 answer
3
3 votes
3 votes
1 answer
4
Sanjay Sharma asked Feb 20, 2018
1,106 views
An array A is of length n has log( n) distinct numbers.What is the time complexity of sorting A by best comparison based algorithm ?