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
What is the time complexity of binary search on a sorted array?
AO(n)
BO(1)
CO(n log n)
DO(log n)
2.Easy
What is the running time of counting sort for n integers in the range 0 to k?
AO(n + k)
BO(n log n)
CO(k log n)
DO(n²)
3.Easy
What is the time complexity of linear search in an unsorted array of n elements (worst case)?
AO(log n)
BO(n)
CO(1)
DO(n²)
4.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
AO(log n)
BO(n²)
CO(n log n)
DO(n)
5.Medium
What is the time complexity of the Bellman–Ford algorithm on a graph with V vertices and E edges?
AO(V × E)
BO(V + E)
CO(E log V)
DO(V³ × E)
6.Medium
What is the worst-case time complexity of quicksort?
AO(n log n)
BO(n²)
CO(n)
DO(log n)
7.Hard
Shortest simple paths can be found in polynomial time. What is known about finding the longest simple path between two vertices in a general graph?
AIt can be solved by Dijkstra's algorithm with negated weights
BIt is NP-hard
CIt is always solvable in O(V + E)
DIt is undecidable
8.Hard
Why does binary search not give O(log n) time on a singly linked list?
ALinked lists cannot be sorted
BComparisons on linked list nodes are slower
CReaching the middle element takes O(n) steps, since there is no direct index access
DBinary search needs at least twice the memory
Answer key
1. D · O(log n)
2. A · O(n + k)
3. B · O(n)
4. C · O(n log n)
5. A · O(V × E)
6. B · O(n²)
7. B · It is NP-hard
8. C · Reaching the middle element takes O(n) steps, since there is no direct index access
Full step-by-step solutions: practise this topic on examproblems.com.