1.Easy
What is the time complexity of binary search on a sorted array?
- AO(n log n)
- BO(n)
- CO(log n)
- DO(1)
2.Easy
What does the average-case running time describe?
- AThe middle value between the best-case and worst-case running times
- BThe time for an input of average length
- CThe expected time over a given distribution of inputs of size n
- DThe time on the most common computer
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 time complexity of: for i = 1 to n: (j = 1; while j < n: j = j × 2)?
- AO(n)
- BO(n log n)
- CO(n²)
- DO(log n)
5.Medium
What does the recurrence T(n) = T(n − 1) + O(1) solve to?
- AO(2ⁿ)
- BO(n²)
- CO(log n)
- DO(n)
6.Medium
A greedy algorithm:
- ATries every possible solution
- BAlways gives the optimal solution
- CMakes the locally best choice at each step
- DUses only recursion
7.Hard
Which definition of the class P is correct?
- AProblems that can be solved in parallel
- BDecision problems solvable by a deterministic algorithm in polynomial time
- CProblems that need exponential time on every computer
- DProblems whose solutions can be checked but never found in polynomial time
8.Hard
What did the Cook–Levin theorem establish?
- AEvery NP problem can be solved in exponential time
- BP is not equal to NP
- CThe Boolean satisfiability problem (SAT) is NP-complete
- DThe halting problem is undecidable
Answer key
- 1. C · O(log n)
- 2. C · The expected time over a given distribution of inputs of size n
- 3. D · O(n log n)
- 4. B · O(n log n)
- 5. D · O(n)
- 6. C · Makes the locally best choice at each step
- 7. B · Decision problems solvable by a deterministic algorithm in polynomial time
- 8. C · The Boolean satisfiability problem (SAT) is NP-complete
Full step-by-step solutions: practise this topic on examproblems.com.