GATEverse Practice, past papers & mock tests
GATE 2007
AlgorithmsAlgorithm Analysis and Asymptotic NotationseasyMCQ1 mark
Consider the following C code segment:
c
int IsPrime(int n) {
    int i;
    for (i = 2; i <= sqrt(n); i++)
        if (n % i == 0) {
            printf("Not Prime\n");
            return 0;
        }
    return 1;
}
Let T(n) denote the number of times the for loop is executed by the program on input n. Which of the following is TRUE?
Save your progress

Related Algorithms PYQs