1.Easy
Accessing an element by index in an array takes:
- AO(1)
- BO(log n)
- CO(n)
- DO(n²)
2.Easy
What does binary search require of its input?
- AThe array must be sorted
- BThe array must contain only positive numbers
- CThe array length must be a power of two
- DThe array must have no more than 1000 elements
3.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
4.Medium
Which statement about a recursive function without a reachable base case is correct?
- AIt returns 0 automatically
- BIt runs in O(1) time
- CIt keeps calling itself until the call stack overflows
- DThe compiler always turns it into a loop that ends safely
5.Medium
What is the time complexity of computing the n-th Fibonacci number with a bottom-up table?
- AO(2ⁿ)
- BO(n²)
- CO(log n)
- DO(n)
6.Medium
What does amortised analysis measure?
- AThe average cost per operation over a worst-case sequence of operations
- BThe cost of the single most expensive operation anywhere in the sequence
- CThe cost of an algorithm on the best input
- DThe expected cost over random inputs
7.Hard
For which knapsack variant does the greedy rule "take items in order of value per weight" always give an optimal answer?
- AThe fractional knapsack, where items may be split
- BThe 0/1 knapsack, where items must always be taken whole
- CNeither variant
- DBoth variants
8.Hard
Which statement about selecting the k-th smallest element of an unsorted array is correct?
- ASelection always needs Ω(n log n) because it requires sorting
- BQuickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
- CQuickselect runs in O(log n) worst case, because it recurses on only one side of the pivot
- DSelection is only possible in O(n²)
Answer key
- 1. A · O(1)
- 2. A · The array must be sorted
- 3. D · One that tries all possible candidate solutions
- 4. C · It keeps calling itself until the call stack overflows
- 5. D · O(n)
- 6. A · The average cost per operation over a worst-case sequence of operations
- 7. A · The fractional knapsack, where items may be split
- 8. B · Quickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
Full step-by-step solutions: practise this topic on examproblems.com.