int foo(int n)
if(n > 10000)
int sum = 0, i;
for( i = 0; i < n; i++)
sum += i;
The value returned by the above function is
for loop will run 10000 times.
Sum is sum of 1st 9999 natural numbers.
Sum = 9999*10000/2 = 49995000 = Θ(1)
for loop will run 10000 times only if n is given as 1000. Right?
Answer : C
WE always take very large value of n to find Time Complexity . so , here we can ignore loop because it will run only for n <= 10000 . so, here for n > 10000 it run only for 1 time for any large value . so , time complexity = Big Theta(1) // which is average case time complexity