1.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(n)
- BO(n log n)
- CO(1)
- DO(log n)
2.Easy
What does the worst-case running time of an algorithm describe?
- AThe expected time it takes on a random input of size n
- BThe time it takes on a slow computer
- CThe time it takes on the smallest input
- DThe maximum time it takes over all inputs of size n
3.Easy
What is the time complexity of binary search on a sorted array?
- AO(n log n)
- BO(1)
- CO(log n)
- DO(n)
4.Medium
A greedy algorithm:
- AUses only recursion
- BAlways gives the optimal solution
- CMakes the locally best choice at each step
- DTries every possible solution
5.Medium
With coins of 1, 3 and 4 and an amount of 6, how many coins does the greedy "largest coin first" method use, compared to the optimum?
- AGreedy uses 3 coins; the optimum is 2
- BGreedy uses 3 coins; the optimum is 3
- CGreedy uses 2 coins; the optimum is 2
- DGreedy uses 4 coins; the optimum is 3
6.Medium
What is the time complexity of computing the n-th Fibonacci number with a bottom-up table?
- AO(n)
- BO(2ⁿ)
- CO(n²)
- DO(log n)
7.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX has no polynomial algorithm, and X is decidable
- BX is in NP, and a known NP-complete problem reduces to X in polynomial time
- CX is in P, and X reduces to SAT
- DX reduces to a problem in P, and X is in NP
8.Hard
Insertion sort runs in O(n) on sorted input. Does this contradict the Ω(n log n) lower bound for comparison sorting?
- ANo, the lower bound applies to the worst case over all inputs, not to every input
- BYes, but only for arrays shorter than 100
- CYes, the lower bound is therefore wrong
- DNo, because insertion sort is not a comparison sort
Answer key
- 1. A · O(n)
- 2. D · The maximum time it takes over all inputs of size n
- 3. C · O(log n)
- 4. C · Makes the locally best choice at each step
- 5. A · Greedy uses 3 coins; the optimum is 2
- 6. A · O(n)
- 7. B · X is in NP, and a known NP-complete problem reduces to X in polynomial time
- 8. A · No, the lower bound applies to the worst case over all inputs, not to every input
Full step-by-step solutions: practise this topic on examproblems.com.