Asymptotic Analysis & Recurrences

Answer & solution
Answer: B (no official key was published)
1. Approach. A uniform lower bound must apply to easy inputs too. Even numbers terminate at i=2, whereas prime numbers make the loop test all candidate divisors through floor(√n).
2. Derivation and interpretation. Under the intended interpretation that n is the positive input integer, at most floor(sqrt(n))−1 candidate divisors are tested, so T(n)=O(sqrt(n)). For even n≥4, the first divisor i=2 causes immediate return, so T(n)=1 on an unbounded input family and no uniform Ω(sqrt(n)) lower bound is valid. For all sufficiently large n at least one iteration occurs, establishing Ω(1); B is therefore the intended answer. Prime n attain Θ(sqrt(n)). Source caveat: the printed function uses old-style IsPrime(n) and then declares int i,n inside its body, redeclaring its parameter n in the same scope. This is not valid C as printed; the algorithmic answer requires repairing the parameter declaration/removing the duplicate local n.