1.Easy
What is the time complexity of binary search on a sorted array?
- AO(n log n)
- BO(1)
- CO(n)
- DO(log n)
2.Easy
What does the worst-case running time of an algorithm describe?
- AThe maximum time it takes over all inputs of size n
- BThe time it takes on the smallest input
- CThe expected time it takes on a random input of size n
- DThe time it takes on a slow computer
3.Easy
What does binary search require of its input?
- AThe array must be sorted
- BThe array must have no more than 1000 elements
- CThe array length must be a power of two
- DThe array must contain only positive numbers
4.Medium
What does the recurrence T(n) = T(n − 1) + O(n) solve to?
- AO(n)
- BO(n log n)
- CO(n²)
- DO(2ⁿ)
5.Medium
What does the recurrence T(n) = 2T(n/2) + O(1) solve to?
- AO(log n)
- BO(n log n)
- CO(n)
- DO(n²)
6.Medium
What is the time complexity of computing the n-th Fibonacci number with a bottom-up table?
- AO(n²)
- BO(n)
- CO(2ⁿ)
- DO(log n)
7.Hard
Why does binary search not give O(log n) time on a singly linked list?
- ALinked lists cannot be sorted
- BBinary search needs at least twice the memory
- CComparisons on linked list nodes are slower
- DReaching the middle element takes O(n) steps, since there is no direct index access
8.Hard
What are the time and space costs of computing the n-th Fibonacci number with a loop that keeps only the last two values?
- AO(n) time and O(n) space
- BO(log n) time and O(n) space
- CO(n) time and O(1) space
- DO(2ⁿ) time and O(1) space
Answer key
- 1. D · O(log n)
- 2. A · The maximum time it takes over all inputs of size n
- 3. A · The array must be sorted
- 4. C · O(n²)
- 5. C · O(n)
- 6. B · O(n)
- 7. D · Reaching the middle element takes O(n) steps, since there is no direct index access
- 8. C · O(n) time and O(1) space
Full step-by-step solutions: practise this topic on examproblems.com.