You are on page 1of 2

1.An unordered list contains n distinct elements.

The number of comparisons to find an


element in this list that is neither maximum nor minimum is [GATE CSE 2015]
(A) θ(n log n)
(B) θ(n)
(C) θ(log n)
(D) θ(1)
2.Which one of the following is the recurrence equation for the worst-case time
complexity of the Quicksort algorithm for sorting (n ≥ 2) numbers? In the recurrence
equations given in the options below, c is a constant. [GATE CSE 2015]
(A) T(n) = 2T(n/2) + cn
(B) T(n) = T(n-1) + T(0) + cn
(C) T(n) = 2T(n-1) + cn
(D) T(n) = T(n/2) + cn
3. Which one of the following statements is TRUE for all positive functions f(n)? [GATE
CSE 2022]
(A) f(n2) = θ(f(n)2), when f(n) is a polynomial
(B) f(n2) = o(f(n)2)
(C) f(n2) = O(f(n)2), when f(n) is an exponential function
(D) f(n2) = Ω(f(n)2)
4. The Floyd-Warshall algorithm for all-pair shortest paths computation is based on
[GATE CSE 2016]
(A) Greedy Algorithm
(B) Divide-and-Conquer Paradigm
(C) Dynamic Programming Paradigm
(D) neither Greedy nor Divide-and-Conquer nor Dynamic Programming Paradigm
Question 5
5. What is time complexity of fun()?
int fun(int n)
{
int count = 0;
for (int i = n; i > 0; i /= 2)
for (int j = 0; j < i; j++)
count += 1;
return count;
}
A O(n^2)
B O(nLogn)
C O(n)
D O(nLognLogn)

6. What is the time complexity of fun()?


int fun(int n)
{
int count = 0;
for (int i = 0; i < n; i++)
for (int j = i; j > 0; j--)
count = count + 1;
return count;
}
A Theta (n)
B Theta (n^2)
C Theta (n*Logn)
D Theta (nLognLogn)

7. What is the time complexity of the below function?


void fun(int n, int arr[])
{
int i = 0, j = 0;
for(; i < n; ++i)
while(j < n && arr[i] < arr[j])
j++;
}
A O(n)
B O(n^2)
C O(nlogn)
D O(n(logn)^2)

You might also like