1.Easy
What is the base case of a recursive function?
- AA case that is answered directly without making another recursive call
- BThe case with the largest input, which is handled before any recursive calls
- CThe call that uses the most memory
- DThe first line of the function
2.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(n log n)
- BO(n)
- CO(log n)
- DO(1)
3.Easy
An O(n²) algorithm takes 1 second for n = 1000. About how long does it take for n = 2000?
- A2 seconds
- B4 seconds
- C8 seconds
- D1 second
4.Medium
What is the amortised time complexity of appending to a dynamic array that doubles its capacity when full?
- AO(1)
- BO(n)
- CO(n²)
- DO(log n)
5.Medium
What is the worst-case time complexity of quicksort?
- AO(n log n)
- BO(n)
- CO(log n)
- DO(n²)
6.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- ANo, because Big O must always state the exact growth rate of the function
- BYes, because Big O is an upper bound and n² grows no faster than n³
- CNo, because n³ is smaller than n² for large n
- DYes, but only if n is smaller than 100
7.Hard
Taking both endpoints of every edge in a maximal matching gives a vertex cover. How good is this cover?
- AAt most twice the size of a minimum vertex cover
- BAlways a minimum vertex cover
- CAt most log n times the minimum
- DOf unknown quality compared to the optimum
8.Hard
How does the Bellman–Ford algorithm detect a negative-weight cycle reachable from the source?
- AIt counts the cycles with depth-first search
- BIt checks whether any edge has a negative weight
- CIt runs Dijkstra's algorithm twice and compares the two distance results
- DAfter V − 1 rounds, it checks whether any edge can still be relaxed
Answer key
- 1. A · A case that is answered directly without making another recursive call
- 2. B · O(n)
- 3. B · 4 seconds
- 4. A · O(1)
- 5. D · O(n²)
- 6. B · Yes, because Big O is an upper bound and n² grows no faster than n³
- 7. A · At most twice the size of a minimum vertex cover
- 8. D · After V − 1 rounds, it checks whether any edge can still be relaxed
Full step-by-step solutions: practise this topic on examproblems.com.