1.Easy
Which of these running times is polynomial?
- AO(n³)
- BO(2ⁿ)
- CO(n!)
- DO(nⁿ)
2.Easy
Space complexity measures:
- AThe disk space of the program file once it is compiled
- BThe physical size of the computer
- CThe number of lines of code
- DThe amount of memory an algorithm needs as input grows
3.Easy
What is the worst-case time complexity of merge sort?
- AO(n²)
- BO(n)
- CO(log n)
- DO(n log n)
4.Medium
What is the worst-case time complexity of quicksort?
- AO(log n)
- BO(n log n)
- CO(n)
- DO(n²)
5.Medium
In the activity selection problem, which greedy rule always gives a maximum number of non-overlapping activities?
- APick the activity that starts earliest
- BPick the activity that finishes earliest, then repeat with the compatible ones
- CPick the activity with the fewest overlaps first, then repeat with the compatible ones
- DPick the shortest activity first
6.Medium
What does the Floyd–Warshall algorithm compute, and how fast?
- AA minimum spanning tree in O(E log V)
- BShortest paths between all pairs of vertices in O(V³)
- CShortest paths from one source vertex to all others in O(V + E)
- DA topological order in O(V²)
7.Hard
Which two things must be shown to prove that a decision problem X is NP-complete?
- AX is in NP, and a known NP-complete problem reduces to X in polynomial time
- BX is in P, and X reduces to SAT
- CX reduces to a problem in P, and X is in NP
- DX has no polynomial algorithm, and X is decidable
8.Hard
What would follow if someone found a polynomial-time algorithm for one NP-complete problem?
- AOnly that one problem would move into P
- BAll exponential-time algorithms would immediately run in linear time
- CEvery problem in NP could be solved in polynomial time, so P = NP
- DThe halting problem would become decidable
Answer key
- 1. A · O(n³)
- 2. D · The amount of memory an algorithm needs as input grows
- 3. D · O(n log n)
- 4. D · O(n²)
- 5. B · Pick the activity that finishes earliest, then repeat with the compatible ones
- 6. B · Shortest paths between all pairs of vertices in O(V³)
- 7. A · X is in NP, and a known NP-complete problem reduces to X in polynomial time
- 8. C · Every problem in NP could be solved in polynomial time, so P = NP
Full step-by-step solutions: practise this topic on examproblems.com.