1.Easy
What does the average-case running time describe?
- AThe expected time over a given distribution of inputs of size n
- BThe middle value between the best-case and worst-case running times
- CThe time for an input of average length
- DThe time on the most common computer
2.Easy
An algorithm with two nested loops, each running n times, typically has which complexity?
- AO(log n)
- BO(2n)
- CO(n²)
- DO(n)
3.Easy
Space complexity measures:
- AThe disk space of the program file once it is compiled
- BThe number of lines of code
- CThe physical size of the computer
- DThe amount of memory an algorithm needs as input grows
4.Medium
What is the time complexity of the standard dynamic programming algorithm for the longest common subsequence of strings of lengths m and n?
- AO(m + n)
- BO(2m+n)
- CO(mn log n)
- DO(mn)
5.Medium
How many levels does the recursion of merge sort have for an array of n elements?
- AAbout log₂ n
- BAbout n / 2
- CAbout n
- DAbout √n
6.Medium
What does the recurrence T(n) = 2T(n − 1) + O(1) solve to?
- AO(2ⁿ)
- BO(n log n)
- CO(n)
- DO(n²)
7.Hard
Why can Dijkstra's algorithm give wrong results when some edge weights are negative?
- ANegative numbers cannot be stored in a priority queue
- BA vertex is finalised when extracted, but a later negative edge could still give it a shorter path
- CIt only works on undirected graphs
- DIt goes into an infinite loop on every negative edge
8.Hard
Topological sorting is possible only for:
- AGraphs with negative weights
- BComplete graphs
- CUndirected graphs
- DDirected acyclic graphs
Answer key
- 1. A · The expected time over a given distribution of inputs of size n
- 2. C · O(n²)
- 3. D · The amount of memory an algorithm needs as input grows
- 4. D · O(mn)
- 5. A · About log₂ n
- 6. A · O(2ⁿ)
- 7. B · A vertex is finalised when extracted, but a later negative edge could still give it a shorter path
- 8. D · Directed acyclic graphs
Full step-by-step solutions: practise this topic on examproblems.com.