1
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
In the following C function, let n $$ \ge $$ m.
int gcd(n,m)
{
if (n % m == 0) return m;
n = n % m;
return gcd(m,n);
}
How many recursive calls are made by this function?
A
$$\Theta(\log_2n)$$
B
$$\Omega(n)$$
C
$$\Theta(\log_2\log_2n)$$
D
$$\Theta(\sqrt{n})$$
2
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C code segment:
int IsPrime(n){
 int i, n;
 for(i=2; i<=sqrt(n);i++){
  if(n % i == 0){
    printf("No 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?
A
T(n) = O ($$\sqrt n $$) and T(n) = $$\Omega \,(\sqrt n )$$
B
T(n) = O ($$\sqrt n $$) and T(n) = $$\Omega \,(1)$$
C
T(n) = O (n) and T(n) = $$\Omega \,(\sqrt n )$$
D
None of the above
3
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
What is the time complexity of the following recursive function?
int DoSomething(int n){
 if(n <= 2)
     return 1;
 else
     return (floor(sqrt(n)) + n);
}
A
$$\Theta \,({n^2})$$
B
$$\Theta \,(n\,{\log _2}\,n)$$
C
$$\Theta \,({\log _2}\,n)$$
D
$$\Theta \,({\log _2}\,{\log _2}\,n)$$
4
GATE CSE 2007
MCQ (Single Correct Answer)
+1
-0.3
Which of the following sorting algorithms has the lowest worst-case complexity?
A
Merge sort
B
Bubble sort
C
Quick sort
D
Selection sort
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12