1.Easy
What is the worst-case time complexity of insertion sort?
- AO(n)
- BO(log n)
- CO(n log n)
- DO(n²)
2.Easy
What is recursion?
- AA function that calls itself on smaller inputs
- BA sorting method
- CA type of data structure
- DA loop that never ends
3.Easy
Which design strategy does merge sort use?
- ADivide and conquer
- BDynamic programming
- CBrute force
- DGreedy choice
4.Medium
A greedy algorithm:
- ATries every possible solution
- BAlways gives the optimal solution
- CUses only recursion
- DMakes the locally best choice at each step
5.Medium
What is the time complexity of: for i = 1 to n: for j = 1 to i: do O(1) work?
- AO(n log n)
- BO(n²)
- CO(n)
- DO(n³)
6.Medium
What is the amortised time complexity of appending to a dynamic array that doubles its capacity when full?
- AO(n)
- BO(n²)
- CO(1)
- DO(log n)
7.Hard
Is 22n in O(2ⁿ)?
- ANo, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
- BNo, because 22n grows more slowly than 2ⁿ
- CYes, because both are exponential
- DYes, because constant factors in the exponent are always ignored in Big O
8.Hard
The halting problem shows that:
- ANo algorithm can decide for every program and input whether it halts
- BSome programs run faster on faster computers, so halting depends on hardware
- CEvery program eventually halts
- DLoops should be avoided
Answer key
- 1. D · O(n²)
- 2. A · A function that calls itself on smaller inputs
- 3. A · Divide and conquer
- 4. D · Makes the locally best choice at each step
- 5. B · O(n²)
- 6. C · O(1)
- 7. A · No, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
- 8. A · No algorithm can decide for every program and input whether it halts
Full step-by-step solutions: practise this topic on examproblems.com.