1.Easy
An algorithm's running time is O(n). What is this growth called?
- ALogarithmic
- BLinear
- CConstant
- DQuadratic
2.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- ABubble sort
- BMerge sort
- CQuicksort
- DHeap sort
3.Easy
What is the base case of a recursive function?
- AThe call that uses the most memory
- BThe first line of the function
- CA case that is answered directly without making another recursive call
- DThe case with the largest input, which is handled before any recursive calls
4.Medium
What is the time complexity of: for i = 1 to n: (j = 1; while j < n: j = j × 2)?
- AO(n²)
- BO(n)
- CO(log n)
- DO(n log n)
5.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- AYes, because Big O is an upper bound and n² grows no faster than n³
- BNo, because Big O must always state the exact growth rate of the function
- CNo, because n³ is smaller than n² for large n
- DYes, but only if n is smaller than 100
6.Medium
Quicksort always uses the first element as pivot. On which input does it show its worst-case behaviour?
- AAn array that is already sorted
- BAn array whose elements are all different
- CAn array in random order
- DAn array of length 2
7.Hard
Which statement about selecting the k-th smallest element of an unsorted array is correct?
- AQuickselect runs in O(log n) worst case, because it recurses on only one side of the pivot
- BSelection always needs Ω(n log n) because it requires sorting
- CSelection is only possible in O(n²)
- DQuickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
8.Hard
To show that a new problem X is NP-hard, what must you do?
- AReduce a known NP-hard problem to X in polynomial time
- BShow that X has no polynomial algorithm for small inputs
- CReduce X to a known NP-hard problem in polynomial time
- DShow that X can be verified in polynomial time
Answer key
- 1. B · Linear
- 2. A · Bubble sort
- 3. C · A case that is answered directly without making another recursive call
- 4. D · O(n log n)
- 5. A · Yes, because Big O is an upper bound and n² grows no faster than n³
- 6. A · An array that is already sorted
- 7. D · Quickselect runs in expected O(n), and median-of-medians guarantees O(n) worst case
- 8. A · Reduce a known NP-hard problem to X in polynomial time
Full step-by-step solutions: practise this topic on examproblems.com.