1.Easy
How does selection sort work?
- AIt splits the array in halves and merges them
- BIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- CIt inserts each element into a growing sorted part by shifting
- DIt repeatedly swaps neighbouring elements that are in the wrong order
2.Easy
Space complexity measures:
- AThe physical size of the computer
- BThe amount of memory an algorithm needs as input grows
- CThe disk space of the program file once it is compiled
- DThe number of lines of code
3.Easy
What is the time complexity of binary search on a sorted array?
- AO(log n)
- BO(n log n)
- CO(1)
- DO(n)
4.Medium
Is it correct to say that an O(n²) algorithm is also O(n³)?
- ANo, because n³ is smaller than n² for large n
- BNo, because Big O must always state the exact growth rate of the function
- CYes, because Big O is an upper bound and n² grows no faster than n³
- DYes, but only if n is smaller than 100
5.Medium
A function runs one loop of n iterations and then, separately, another loop of n iterations. What is its time complexity?
- AO(log n)
- BO(2ⁿ)
- CO(n)
- DO(n²)
6.Medium
Breadth-first search on an unweighted graph finds:
- AA topological order in all graphs
- BShortest paths in graphs that contain negative edge weights
- CShortest paths in number of edges from the start node
- DThe minimum spanning tree
7.Hard
The 0/1 knapsack problem solved with dynamic programming takes O(nW) time. Why is this called pseudo-polynomial?
- ABecause it only works for W = 0
- BW is a number, so the time is exponential in the number of bits used to write W
- CBecause the algorithm is randomised and its running time varies with each input
- DBecause n is always small
8.Hard
Strassen's algorithm multiplies matrices using 7 instead of 8 recursive multiplications of half-size blocks. What is its running time?
- AΘ(n² log n)
- BΘ(n³)
- CΘ(nlog₂ 7), about n2.81
- DΘ(n2)
Answer key
- 1. B · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 2. B · The amount of memory an algorithm needs as input grows
- 3. A · O(log n)
- 4. C · Yes, because Big O is an upper bound and n² grows no faster than n³
- 5. C · O(n)
- 6. C · Shortest paths in number of edges from the start node
- 7. B · W is a number, so the time is exponential in the number of bits used to write W
- 8. C · Θ(nlog₂ 7), about n2.81
Full step-by-step solutions: practise this topic on examproblems.com.