664 views
1 votes
1 votes
Please help to find the time complexity of this loop.

void main()

{

int n;

while(n>=1)

{

n=n-2;

}

}

1 Answer

1 votes
1 votes
Since each time the n is decreasing by 2 so overall iterations will become half and time complexity=n/2

Related questions

0 votes
0 votes
0 answers
2
0 votes
0 votes
1 answer
3
NeelParekh asked Jul 27, 2023
263 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
433 views
What is the correct time complexity in $\theta()$ ?