1.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(n log n)
- BO(1)
- CO(log n)
- DO(n)
2.Easy
What is O(2ⁿ) growth called?
- AExponential
- BPolynomial
- CLinear
- DLogarithmic
3.Easy
What is the time complexity of binary search on a sorted array?
- AO(n)
- BO(log n)
- CO(1)
- DO(n log n)
4.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 removes the most expensive edge until no cycles remain
- CIt runs breadth-first search and keeps the BFS tree
- DIt grows one tree from a start vertex, adding the cheapest edge that leaves the tree
5.Medium
Quicksort always uses the first element as pivot. On which input does it show its worst-case behaviour?
- AAn array in random order
- BAn array that is already sorted
- CAn array whose elements are all different
- DAn array of length 2
6.Medium
Which statement about a recursive function without a reachable base case is correct?
- AIt keeps calling itself until the call stack overflows
- BIt runs in O(1) time
- CThe compiler always turns it into a loop that ends safely
- DIt returns 0 automatically
7.Hard
What are the time and space costs of computing the n-th Fibonacci number with a loop that keeps only the last two values?
- AO(n) time and O(n) space
- BO(log n) time and O(n) space
- CO(2ⁿ) time and O(1) space
- DO(n) time and O(1) space
8.Hard
Taking both endpoints of every edge in a maximal matching gives a vertex cover. How good is this cover?
- AAlways a minimum vertex cover
- BAt most log n times the minimum
- COf unknown quality compared to the optimum
- DAt most twice the size of a minimum vertex cover
Answer key
- 1. D · O(n)
- 2. A · Exponential
- 3. B · O(log n)
- 4. D · It grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- 5. B · An array that is already sorted
- 6. A · It keeps calling itself until the call stack overflows
- 7. D · O(n) time and O(1) space
- 8. D · At most twice the size of a minimum vertex cover
Full step-by-step solutions: practise this topic on examproblems.com.