Font size
WorksheetsAsymptotic Notations Practice Questions
Total questions: 58
Worksheet time: 38mins
Which of the following case does not exist in complexity theory?
Best case
•Worst case
•Average case
Null case
•The worst case complexity for insertion sort is _________
•
O(n)
•
O(log n)
•O(n2)
•O(n log n)
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;
•}
Theta (n)
Theta (n^2)
•Theta (n*Logn)
•Theta (nLognLogn)
What does it mean when we say that an algorithm X is asymptotically more efficient than Y?
X will always be a better choice for small inputs
•X will always be a better choice for large inputs
•Y will always be a better choice for small inputs
•X will always be a better choice for all inputs
•What is the time complexity of following code:
•int a = 0, b = 0;
•for (i = 0; i < N; i++) {
•a = a + rand();
•}
•for (j = 0; j < M; j++) {
•b = b + rand();
•}
•O(N * M) time,
•O(N + M) time,
None of these
•To measure Time complexity of an algorithm Big O notation is used which:
describes limiting behaviour of the function
•characterises a function based on growth of function
•upper bound on growth rate of the function
•all of the mentioned
•If for an algorithm time complexity is given by O(n) then complexity of it is:
•constant
•linear
•exponential
•none of the mentioned
•If for an algorithm time complexity is given by O(1) then complexity of it is:
•constant
•polynomial
•exponential
•none of the mentioned
Consider the following three claims
1. (n + k)m = Θ(nm), where k and m are constants
2. 2n + 1 = O(2n)
3. 22n + 1 = O(2n)
Which of these claims are correct ?
(A) 1 and 2
(B) 1 and 3
(C) 2 and 3
(D) 1, 2, and 3
What is the time complexity of this code
int a = 0, i = N;
while (i > 0)
{
a += i;
i /= 2;
}
O(N)
O(Sqrt(N))
O(N / 2)
O(log N)
The complexity of Binary search algorithm is
O(n)
O(log n)
O(n2)
O(n log n)
What is the time complexity of following code:
int a = 0;
for (i = 0; i < N; i++) {
for (j = N; j > i; j--) {
a = a + i + j;
}
}
O(N)
O(N*log(N))
O(N * Sqrt(N))
O(N*N)
What is the time complexity of following code:
int i, j, k = 0;
for (i = n / 2; i <= n; i++) {
for (j = 2; j <= n; j = j * 2) {
k = k + n / 2;
}
}
O(n)
O(nLogn)
O(n^2)
O(n^2Logn)
A linear function takes the form
f(n) = an + b
f(n) = an2 +bn + c
f(n) = alog2n
f(n) = a + b
Find the slowest time complexity
O (n)
O (n^2)
O (n!)
O (2^n)
The number of executions grows extremely quickly as the size of the input increases
Exponential Time
Linear Time
Polynomial Time
Constant Time
What does it mean when we say that an algorithm X is asymptotically more efficient than Y?
X will be a better choice for all inputs
X will be a better choice for all inputs except possibly small inputs
X will be a better choice for all inputs except possibly large inputs
Y will be a better choice for small inputs
Consider the following functions:
f(n) = 2^n
g(n) = n!
h(n) = n^logn
Which of the following statements about the asymptotic behavior of f(n), g(n), and h(n) is true?
f(n) = O(g(n)); g(n) = O(h(n))
f(n) = omega (g(n)); g(n) = O(h(n))
g(n) = O(f(n)); h(n) = O(f(n))
h(n) = O(f(n)); g(n) = omega (f(n))
What is the worst case running time of the above pseudo code?
O(n)
O(n log n)
O(n2)
O(n3)
asymptotic notations represents
space complexity of algo
time complexity of algo
both a and b
none of the above
Big
Ω defineslower bound
upper bound
middle bound
none of the above
This picture represents
big theta noataion
big oh notation
big omega notation
none of the above
Which of the following case does not exist in complexity theory?
Best case
•Worst case
•Average case
Null case
big O represents
best case scenario
worst case scenario
average case scenario
none of the above
What is an Algorithm?
A set of instructions that, when executed, completes a defined task that solves a problem.
The process of breaking apart a problem.
The process of removing unnecessary detail.
A sequence of instructions.
Time Complexity of this program:
def f():
a = 0
for i = 1 to n:
a += i;
b = 0
for i = 1 to m:
b += i;
O(n)
O(m)
O(n+m)
O(n*m)
If for an algorithm time complexity is given by O(1) then complexityof it is:
constant
polynomial
exponential
none of the mentioned
If for an algorithm time complexity is given by O(n) then complexityof it is:
A. constant
B. linear
C. exponential
D. none of the mentioned
To measure Time complexity of an algorithm Big O notation is used which:
A. describes limiting behaviour of the function
B. characterises a function based on growth of function
C. upper bound on growth rate of the function
D. all of the mentioned
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Constant
What order of complexity does this graph represent?
Exponential
Polynomial
Linear
Logarithmic
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3 and f4?
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = nLogn
f4(n) = n^(Logn)
f3, f2, f4, f1
f3, f2, f1, f4
f2, f3, f1, f4
f2, f3, f4, f1
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3,f4 and f5?
f1(n) = Logn
f2(n) = n
f3(n) = nLogn
f4(n) = n!
f5(n)=n^2
f3, f2, f4, f1,f5
f3, f2, f1, f4,f5
f2, f3, f1, f4,f5
f1, f2, f3, f5,f4
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the time complexity of this algorithm?
O(n)
O(2n)
O(log n)
O(n2)
O(1)
What is the Big-O Notation of picking a sequence of n balls from a bag of n different coloured balls (the ball is not put back into the bag after being picked)?
O(n)
O(n!)
O(log n)
O(n2)
O(1)
What is the Big-O Notation of a combination lock with n digits, each digit having 1 of 10 possible values?
O(n)
O(10n)
O(log n)
O(n2)
O(1)
The linear/sequential search method to search an element in an array has the complexity of BigO(?)
n
n-1
n^2
n logn
What does a logarithmic time complexity mean?
The time taken to complete an algorithm will increase at a smaller rate as the number of elements inputted.
The amount of time taken to complete an algorithm is proportional to 2 to the power of the number of items inputted.
The amount of time taken to complete an algorithm is proportional to the number of items inputted to the power of n
The amount of time taken to complete an algorithm is independent to the number of inputted elements
What does an exponential time complexity mean?
The amount of time taken to complete an algorithm is proportional to 2 to the power of the number of items inputted.
The amount of time taken to complete an algorithm is proportional to the number of items inputted to the power of n
The amount of time taken to complete an algorithm is independent to the number of inputted elements
The time taken to complete an algorithm will increase at a smaller rate as the number of elements inputted.
What does a polynomial time complexity mean?
The amount of time taken to complete an algorithm is proportional to the number of items inputted to the power of n
The amount of time taken to complete an algorithm is independent to the number of inputted elements
The amount of time taken to complete an algorithm is proportional to 2 to the power of the number of items inputted.
The time taken to complete an algorithm will increase at a smaller rate as the number of elements inputted.
What does a constant time complexity mean?
The amount of time taken to complete an algorithm is independent to the number of inputted elements
The time taken to complete an algorithm will increase at a smaller rate as the number of elements inputted.
The amount of time taken to complete an algorithm is proportional to the number of items inputted to the power of n
The amount of time taken to complete an algorithm is proportional to 2 to the power of the number of items inputted.
which are asymptotic notations
O
Ɵ
Ω
All of above
which asymptotic notations is used for upper bound
O
Ɵ
Ω
All of above
which asymptotic notations is used for lower bound
O
Ɵ
Ω
All of above
which asymptotic notations is used for lower and upper bound
O
Ɵ
Ω
All of above
Can we say big O denotes worst case , theta denotes average case and omega denotes best case
yes
no
may be
An algorithm written recursively have same time complexity when it is written in iterative manner
Always same complexity
Sometimes same complexity
Never same complexity
Can't Say
The most important characteristic of algorithm is
Input
Output
Effective
Finite
Defined
