1.Easy
An algorithm with two nested loops, each running n times, typically has which complexity?
- AO(log n)
- BO(n)
- CO(2n)
- DO(n²)
2.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- ABubble sort
- BMerge sort
- CHeap sort
- DQuicksort
3.Easy
What does binary search require of its input?
- AThe array length must be a power of two
- BThe array must contain only positive numbers
- CThe array must be sorted
- DThe array must have no more than 1000 elements
4.Medium
What is the time complexity of computing the n-th Fibonacci number with a bottom-up table?
- AO(2ⁿ)
- BO(log n)
- CO(n)
- DO(n²)
5.Medium
What is the time complexity of the Bellman–Ford algorithm on a graph with V vertices and E edges?
- AO(V + E)
- BO(E log V)
- CO(V³ × E)
- DO(V × E)
6.Medium
Why do many library sorting routines switch to insertion sort for very small subarrays?
- AInsertion sort has little overhead and is fast on small or nearly sorted inputs
- BInsertion sort is O(n log n) in the worst case
- CInsertion sort uses less memory than any other sorting algorithm on large inputs
- DRecursive algorithms cannot handle arrays below 10 elements
7.Hard
The halting problem shows that:
- ANo algorithm can decide for every program and input whether it halts
- BEvery program eventually halts
- CSome programs run faster on faster computers, so halting depends on hardware
- DLoops should be avoided
8.Hard
Karatsuba multiplication satisfies T(n) = 3T(n/2) + O(n). What does this solve to?
- AΘ(n log n)
- BΘ(n3)
- CΘ(nlog₂ 3), about n1.585
- DΘ(n²)
Answer key
- 1. D · O(n²)
- 2. A · Bubble sort
- 3. C · The array must be sorted
- 4. C · O(n)
- 5. D · O(V × E)
- 6. A · Insertion sort has little overhead and is fast on small or nearly sorted inputs
- 7. A · No algorithm can decide for every program and input whether it halts
- 8. C · Θ(nlog₂ 3), about n1.585
Full step-by-step solutions: practise this topic on examproblems.com.