1.Easy
What is a brute-force algorithm?
- AOne that always uses recursion
- BOne that runs on many processors
- COne that guesses an answer at random
- DOne that tries all possible candidate solutions
2.Easy
What are the three steps of a divide-and-conquer algorithm?
- ARead, compute, write
- BDivide, conquer, combine
- CSort, search, return
- DGuess, check, repeat
3.Easy
How does selection sort work?
- AIt splits the array in halves and merges them
- BIt repeatedly swaps neighbouring elements that are in the wrong order
- CIt inserts each element into a growing sorted part by shifting
- DIt repeatedly finds the minimum of the unsorted part and swaps it to the front
4.Medium
What is the time complexity of: for i = 1 to n: (j = 1; while j < n: j = j × 2)?
- AO(log n)
- BO(n²)
- CO(n log n)
- DO(n)
5.Medium
Why is the base of a logarithm usually left out in Big O, as in O(log n)?
- AAll logarithms in computer science have base 10, so it is implied
- BThe base only matters for small n
- CLogarithms with different bases differ only by a constant factor
- DLogarithms are always rounded to integers
6.Medium
What does the recurrence T(n) = 2T(n − 1) + O(1) solve to?
- AO(2ⁿ)
- BO(n²)
- CO(n log n)
- DO(n)
7.Hard
The halting problem shows that:
- AEvery program eventually halts
- BNo algorithm can decide for every program and input whether it halts
- CSome programs run faster on faster computers, so halting depends on hardware
- DLoops should be avoided
8.Hard
Is 22n in O(2ⁿ)?
- AYes, because both are exponential
- BYes, because constant factors in the exponent are always ignored in Big O
- CNo, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
- DNo, because 22n grows more slowly than 2ⁿ
Answer key
- 1. D · One that tries all possible candidate solutions
- 2. B · Divide, conquer, combine
- 3. D · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 4. C · O(n log n)
- 5. C · Logarithms with different bases differ only by a constant factor
- 6. A · O(2ⁿ)
- 7. B · No algorithm can decide for every program and input whether it halts
- 8. C · No, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
Full step-by-step solutions: practise this topic on examproblems.com.