edited by
1,940 views
0 votes
0 votes

What is  the time complexity of the following code?
 

int j = 0;
for(i=0;i<n;i++)
    {
    for(i=0;i<2n;i++)
        {
        while(j<n)  
            {
              j++;
            }
        }
    }


a) O(n$^{4}$)

b) O(n$^{3}$)

c) O(n$^{2}$)

d) O(n)

I am getting option O(n$^{2}$)  and answer is given O(n)

Explain briefly.

edited by

1 Answer

Related questions

0 votes
0 votes
0 answers
2
0 votes
0 votes
1 answer
3
NeelParekh asked Jul 27, 2023
279 views
If an array is split in the form of increasing and decreasing order then what is TC to find minimum element in the array?
2 votes
2 votes
1 answer
4
h4kr asked Dec 30, 2022
473 views
What is the correct time complexity in $\theta()$ ?