1.Easy
An O(n²) algorithm takes 1 second for n = 1000. About how long does it take for n = 2000?
- A1 second
- B2 seconds
- C8 seconds
- D4 seconds
2.Easy
How does selection sort work?
- AIt splits the array in halves and merges them
- BIt inserts each element into a growing sorted part by shifting
- CIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- DIt repeatedly swaps neighbouring elements that are in the wrong order
3.Easy
What does it mean if an operation runs in O(1) time?
- AIts running time does not grow with the input size
- BIt processes exactly one element per second of running time
- CIt always takes exactly one second
- DIt can only be run once
4.Medium
Why does dynamic programming give no real speed-up for merge sort?
- AMerge sort is already O(n)
- BIts subproblems do not overlap, so there is nothing to reuse
- CDynamic programming only works on graph problems, not on arrays
- DMerge sort has no recursive structure
5.Medium
Which algorithm finds the shortest paths from one source in a graph with non-negative edge weights?
- ADijkstra's algorithm
- BDepth-first search
- CBellman–Ford is required in all cases
- DKruskal's algorithm
6.Medium
What does the recurrence T(n) = T(n − 1) + O(1) solve to?
- AO(n²)
- BO(log n)
- CO(2ⁿ)
- DO(n)
7.Hard
Which of these satisfiability problems is known to be solvable in polynomial time?
- AGeneral SAT on formulas in conjunctive normal form
- B3-SAT, where each clause has exactly three literals
- C2-SAT, where each clause has at most two literals
- DCircuit satisfiability
8.Hard
For which knapsack variant does the greedy rule "take items in order of value per weight" always give an optimal answer?
- ANeither variant
- BThe 0/1 knapsack, where items must always be taken whole
- CBoth variants
- DThe fractional knapsack, where items may be split
Answer key
- 1. D · 4 seconds
- 2. C · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 3. A · Its running time does not grow with the input size
- 4. B · Its subproblems do not overlap, so there is nothing to reuse
- 5. A · Dijkstra's algorithm
- 6. D · O(n)
- 7. C · 2-SAT, where each clause has at most two literals
- 8. D · The fractional knapsack, where items may be split
Full step-by-step solutions: practise this topic on examproblems.com.