Asymptotic Notation · Algorithms
40 questions · asked in 21 of 27 years (2000–2026)
MCQ 37 · MSQ 2 · NAT 11-mark 27 · 2-mark 13
2000Questions per year2026
Questions 1–5 of 40
Consider the following functions, where is a positive integer.
Which one of the following options lists the functions in increasing order of asymptotic growth rate?
Note: Assume the base of log to be .
Which one of the following options lists the functions in increasing order of asymptotic growth rate?
Note: Assume the base of log to be .
Answer: (A)
Look at how fast each function grows (here the log is with base ):
- : this is the slowest of all. It grows slower than any polynomial.
- : this is a polynomial with a small fractional power. It grows faster than any power of , but slower than itself.
- (raising base to the power just gives back ). So it grows just like , which is faster than .
- : by Stirling's approximation, . This grows faster than alone, and so faster than .
So the increasing order is: .
Answer: log(n), n^(1/3), 2^log(n), log(n!)
- : this is the slowest of all. It grows slower than any polynomial.
- : this is a polynomial with a small fractional power. It grows faster than any power of , but slower than itself.
- (raising base to the power just gives back ). So it grows just like , which is faster than .
- : by Stirling's approximation, . This grows faster than alone, and so faster than .
So the increasing order is: .
Answer: log(n), n^(1/3), 2^log(n), log(n!)
Consider an array of integers of size . The indices of run from to . An algorithm is to be designed to check whether satisfies the condition given below.
such that
Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
such that
Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
Answer: (A)
The condition applies to every pair of indices , with both indices in . The difference must be larger than . So the list of consecutive differences has to be strictly increasing. This means the array is "convex".
One pass over the array is enough to check this. Compute each and test for every consecutive pair. Stop at once and answer "no" the first time a test fails. This takes time. It is also optimal, because every element of the array must be looked at at least once to confirm the condition.
Answer:
One pass over the array is enough to check this. Compute each and test for every consecutive pair. Stop at once and answer "no" the first time a test fails. This takes time. It is also optimal, because every element of the array must be looked at at least once to confirm the condition.
Answer:
Given an integer array of size , we want to check if the array is sorted (in either ascending or descending order). An algorithm solves this problem by making a single pass through the array and comparing each element of the array only with its adjacent elements. The worst-case time complexity of this algorithm is
Answer: (A)
The algorithm looks at each pair of adjacent elements one time. In the worst case it makes comparisons. This happens when the array is really sorted, because it must check every pair before it says YES.
It cannot do fewer checks, since any element it does not look at could break the order. So the worst case is . That means it is both and .
Answer: both and
It cannot do fewer checks, since any element it does not look at could break the order. So the worst case is . That means it is both and .
Answer: both and
Let and be functions of natural numbers given by and .
Which of the following statements is/are TRUE?
Which of the following statements is/are TRUE?
One or more options are correct.
Answer: (A), (C)
Take the limit: . So f grows strictly slower than g.
- TRUE
- (strictly smaller) TRUE
- and FALSE
Answer: and
- TRUE
- (strictly smaller) TRUE
- and FALSE
Answer: and
Consider functions Function 1 and Function 2 expressed in pseudocode as follows:
Let and denote the number of times the statement is executed in Function 1 and Function 2, respectively.
Which of the following statements is/are TRUE?
Let and denote the number of times the statement is executed in Function 1 and Function 2, respectively.
Which of the following statements is/are TRUE?
One or more options are correct.
Answer: (A), (D)
Count the number of times x = x + 1 is executed in each function:
- Function 1: the inner loop runs n times, then n/2, then n/4, times. So .
- Function 2: .
Both counts grow in a linear way: and . Neither is strictly smaller or strictly larger than the other, so o and are false.
Answer: and
- Function 1: the inner loop runs n times, then n/2, then n/4, times. So .
- Function 2: .
Both counts grow in a linear way: and . Neither is strictly smaller or strictly larger than the other, so o and are false.
Answer: and
Keep practising