1.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(n)
- BO(log n)
- CO(1)
- DO(n log n)
2.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- ABubble sort
- BHeap sort
- CMerge sort
- DQuicksort
3.Easy
What is log₂ 1024?
- A32
- B12
- C10
- D512
4.Medium
Why does dynamic programming give no real speed-up for merge sort?
- AMerge sort has no recursive structure
- BDynamic programming only works on graph problems, not on arrays
- CIts subproblems do not overlap, so there is nothing to reuse
- DMerge sort is already O(n)
5.Medium
What does it mean that a problem has optimal substructure?
- AEvery subproblem has the same size
- BThe problem has exactly one optimal solution, which every subproblem shares
- CAn optimal solution can be built from optimal solutions of its subproblems
- DThe problem can be solved in constant time
6.Medium
How much stack space does a simple recursive factorial function fact(n) = n × fact(n − 1) use?
- AO(1)
- BO(n)
- CO(n²)
- DO(log n)
7.Hard
Which algorithm finds a minimum spanning tree by repeatedly adding the cheapest edge that does not form a cycle?
- AKruskal's algorithm
- BFloyd–Warshall
- CDijkstra's algorithm
- DPrim's algorithm starting from one node
8.Hard
Is 22n in O(2ⁿ)?
- AYes, because both are exponential
- BNo, because 22n grows more slowly than 2ⁿ
- CYes, because constant factors in the exponent are always ignored in Big O
- DNo, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
Answer key
- 1. A · O(n)
- 2. A · Bubble sort
- 3. C · 10
- 4. C · Its subproblems do not overlap, so there is nothing to reuse
- 5. C · An optimal solution can be built from optimal solutions of its subproblems
- 6. B · O(n)
- 7. A · Kruskal's algorithm
- 8. D · No, because 22n = 4ⁿ and 4ⁿ / 2ⁿ = 2ⁿ grows without bound
Full step-by-step solutions: practise this topic on examproblems.com.