Asymptotic Notation · Algorithms
40 questions · asked in 21 of 27 years (2000–2026)
MCQ 37 · MSQ 2 · NAT 11-mark 27 · 2-mark 13
Questions 36–40 of 40
Answer: (C)
Upper bound: binary search over for the largest with . At each step take the middle value , compute and compare it with . If move up, else move down. The range halves each time, so there are about steps. Each step multiplies numbers of bits, and ordinary multiplication takes bit operations. So the total is , a power of .
(A) is wrong because is far smaller than , so the cost is . (B) is wrong because the cost is with .
Lower bound: the cube root has about bits, and the algorithm must write all of them. So the time is . Since grows faster than any power of , the cost is not for any constant . This rules out (D).
Answer: (C)
1. , where k and m are constants
2.
3.
Which of these claims are correct?
Answer: (A)
Claim 2. , so it is with constant 2. True.
Claim 3. , so . This ratio grows without bound, so no constant gives . False.
Claims 1 and 2 are correct.
Answer: (A)
Answer: (B)
Compare the two functions with a limit:
First find . This is of the form , so apply L'Hôpital's rule. Each use lowers the power of by one and brings out a factor (use natural log; another base only changes a constant):
(The same works for any positive integer power in place of 9.)
So . This means , so . A ratio that goes to infinity is not bounded by any constant, so .
That is exactly option (B). Options (A) and (D) claim , which is false. Option (C) claims , which is false.
Answer: (B)
Which of the following is true?
Answer: (D)
Rewrite using :
So . The two functions differ only by the constant factor 3, so each one is of the other.
For , the top factors are each at least , so . Taking gives about , which is far more than for large . So grows faster than both and .
(A) h(n) is O(f(n)): false, grows faster.
(B) h(n) is O(g(n)): false, same reason.
(C) g(n) is not O(f(n)): false, because , so is .
(D) f(n) is O(g(n)): true, because .
Answer: (D)
Answer: (A)
S is sorted in ascending order: . For any two different elements and with , we have and . So the smallest possible pair sum is .
Some pair has sum less than 1000 exactly when . One addition and one comparison decide this, however large is, so . (If the array were sorted in descending order, the last two elements would be used instead.)
Options (B), (C) and (D) all say the time grows with , which is wrong.
Answer: (A)
Keep practising