1.Easy
Which of these grows slowest as n becomes large?
- AO(n log n)
- BO(n)
- CO(n²)
- DO(log n)
2.Easy
How does selection sort work?
- AIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- BIt splits the array in halves and merges them
- CIt inserts each element into a growing sorted part by shifting
- DIt repeatedly swaps neighbouring elements that are in the wrong order
3.Easy
A problem is usually called tractable if:
- AIt has no solution
- BIt can be solved in polynomial time
- CIt can only be solved by trying every possibility
- DIt can be solved in constant time
4.Medium
The lower bound for comparison-based sorting in the worst case is:
- AΩ(n log n)
- BΩ(n)
- CΩ(n²)
- DΩ(log n)
5.Medium
In a sorted array, you look for two elements that sum to a target by moving one pointer from each end inwards. What is the time complexity?
- AO(n²)
- BO(n log n)
- CO(log n)
- DO(n)
6.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 of length 2
- CAn array that is already sorted
- DAn array whose elements are all different
7.Hard
What is the running time of Dijkstra's algorithm with a binary heap on a graph with V vertices and E edges?
- AO(V + E)
- BO((V + E) log V)
- CO(V × E)
- DO(V³)
8.Hard
Which definition of the class NP is correct?
- ADecision problems whose yes-answers can be verified in polynomial time given a certificate
- BProblems that are not polynomial
- CProblems that no algorithm can solve
- DProblems that cannot be solved in polynomial time
Answer key
- 1. D · O(log n)
- 2. A · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 3. B · It can be solved in polynomial time
- 4. A · Ω(n log n)
- 5. D · O(n)
- 6. C · An array that is already sorted
- 7. B · O((V + E) log V)
- 8. A · Decision problems whose yes-answers can be verified in polynomial time given a certificate
Full step-by-step solutions: practise this topic on examproblems.com.