Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?
GATE CSE · Algorithms
Generate diverse GATE-level questions covering time and space complexity, Big-O, Theta, Omega notations, best/worst/average cases, and comparison of growth rates.
103 questions · 20 PYQs · 0 AI practice · GATE CSE 2027
Let W(n) and A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?
Which of the given options provides the increasing order of asymptotic complexityoffunctions f1, f2, f3 and f4?
Two alternative packages A and B are available for processing a database having records. Package A requires 0.0001 time units and package B requires time units to process n records. What is the smallest value of k for which package B will be preferred over A?
Arrange the following functions in increasing asymptotic order: a. b. c. d. e.
Consider the following C functions:
int f1(int n) {
if(n == 0 || n == 1) return n;
else return (2*f1(n-1) + 3*f1(n-2));
}
int f2(int n) {
int i;
int X[N], Y[N], Z[N] ;
X[0] = Y[0] = Z[0] = 0;
X[1] = 1;
Y[1] = 2;
Z[1] = 3;
for(i = 2; i <= n; i++) {
X[i] = Y[i-1] + Z[i-2];
Y[i] = 2*X[i];
Z[i] = 3*X[i];
}
return X[n] ;
}
The running time of f1(n) and f2(n) are
Consider the following functions: Which of the following statements about the asymptotic behaviour of f(n), g(n), and h(n) is true?
Exponentiation is a heavily used operation in public key cryptography. Which of the following options is the tightest upper bound on the number of multiplications required to compute ?
What is the Asymptotic Notation of the following recursive function:
int DoSomething (int n) {
if (n <= 2) return 1;
else return (DoSomething (floor(sqrt(n))) + n);
}
In the following C function, let n 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?
The time taken by binary search algorithm to search a key in a sorted array of n elements is
Consider the following C code segment:
int IsPrime(n) {
int i,n;
for(i=2;i<=sqrt(n);i++) if(n%i == 0) {
printf("Not Primen");
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?
Consider the following C-program fragment in which i, j,and n are integer variables. for (i = n, j = 0; i > 0; i/=2, j += i); Let Val(j) denote the value stored in the variable j after termination of the for loop. Which one of the following is true?
The Asymptotic Notation of computing the transitive closure of a binary relation on a set of n elements is known to be:
Consider the following C-function:
double foo (int n) {
int i;
double sum;
if (n = = 0) return 1.0;
else {
sum = 0.0;
for (i = 0; i < n; i++) sum += foo (i);
return sum;
}
}
The Asymptotic Notation of space complexity of the above function is:
Consider the following C-function:
double foo (int n) {
int i;
double sum;
if (n = = 0) return 1.0;
else {
sum = 0.0;
for (i = 0; i < n; i++) sum += foo (i);
return sum;
}
}
Suppose we modify the above function foo() and store the values of foo (i), , as and when they are computed. With this modification, the time complexity for function foo() is significantly reduced. The space complexity of the modified function would be:
Let f(n), g(n) and h(n) be functions defined for positive integers such that Which one of the following statements is FALSE?
Let A[1,..., n] be an array storing a bit (1 or 0) at each location, and f(m) is a function whose Asymptotic Notation is (m). Consider the following program fragment written in a C like language: counter = 0; for (i = 1; i < = n; i++) { if (A[i] == 1) counter++; else { f(counter); counter = 0; } } The complexity of this program fragment is
The Asymptotic Notation of the following C function is (assume n 0)
int recursive (int n) {
if (n == 1) return (1);
else return (recursive (n - 1) + recursive (n - 1));
}
The cube root of a natural number n is defined as the largest natural number m such that . The complexity of computing the cube root of n(n is represented in binary notation) is
Consider the following three claims 1. , where k and m are constants 2. 3. Which of these claims are correct?
Want unlimited AI-generated Asymptotic Analysis questions?
Sign up free and practice with adaptive difficulty — Easy, Medium, Hard. New questions every session.
Start practising for free →