ISRO CS 2011
November 9, 2023Question 2053 – Nielit Scientific Assistance CS 15-10-2017
November 9, 2023Question 2052 – Nielit Scientific Assistance CS 15-10-2017
Consider the following C code segment:
int IsPrime(n)
{
int i,n;
for(i=2;i<= √n;i++)
if(n%i == 0)
{
printf(“Not Prime\n”);
return 0;
}
return 1;
}
Let T(n) denotes the number of times the for loop is executed by the program on input n.
Which of the following is TRUE?
Correct Answer: B
Question 6 Explanation:
Then the time complexity is Best Case : Ω(1) & Worst Case: O(√n)
T(n) = O( √n) and T(n) = Ω ( √n)
T(n) = O( √n) and T(n) = Ω (1)
T(n) = O(n) and T(n) = Ω ( √n)
None of the above
Subscribe
Login
0 Comments