For teachers: free to print, copy and use in class. Every new worksheet has new values and its own answer key. A link to ExamProblems on your course page is appreciated.
Name: ____________________ Date: ____________
1.Easy
Which notation describes an upper bound on growth?
ABig Theta
BBig Omega
CBig O
DLittle omega
2.Easy
What is O(2ⁿ) growth called?
AExponential
BLinear
CLogarithmic
DPolynomial
3.Easy
What is the running time of counting sort for n integers in the range 0 to k?
AO(k log n)
BO(n²)
CO(n + k)
DO(n log n)
4.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
AO(log n)
BO(n)
CO(n log n)
DO(n²)
5.Medium
How does Prim's algorithm build a minimum spanning tree?
AIt sorts all edges by weight and adds each one unless it would form a cycle in the forest
BIt runs breadth-first search and keeps the BFS tree
CIt removes the most expensive edge until no cycles remain
DIt grows one tree from a start vertex, adding the cheapest edge that leaves the tree
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
AO(n²)
BO(n log n)
CO(log n)
DO(n)
7.Hard
The 0/1 knapsack problem solved with dynamic programming takes O(nW) time. Why is this called pseudo-polynomial?
ABecause the algorithm is randomised and its running time varies with each input
BW is a number, so the time is exponential in the number of bits used to write W
CBecause n is always small
DBecause it only works for W = 0
8.Hard
What is the time complexity of: for i = 1 to n: for (j = i; j ≤ n; j = j + i) do O(1) work?
AO(n log n)
BO(n √n)
CO(n²)
DO(n)
Answer key
1. C · Big O
2. A · Exponential
3. C · O(n + k)
4. B · O(n)
5. D · It grows one tree from a start vertex, adding the cheapest edge that leaves the tree
6. B · O(n log n)
7. B · W is a number, so the time is exponential in the number of bits used to write W
8. A · O(n log n)
Full step-by-step solutions: practise this topic on examproblems.com.