1.Easy
What is the time complexity of depth-first search on a graph stored as adjacency lists?
- AO(V × E)
- BO(E log V)
- CO(V + E)
- DO(V²)
2.Easy
Which of these grows slowest as n becomes large?
- AO(log n)
- BO(n²)
- CO(n log n)
- DO(n)
3.Easy
What does binary search require of its input?
- AThe array length must be a power of two
- BThe array must contain only positive numbers
- CThe array must have no more than 1000 elements
- DThe array must be sorted
4.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(log n)
- BO(n²)
- CO(n)
- DO(n log n)
5.Medium
What is the amortised time complexity of appending to a dynamic array that doubles its capacity when full?
- AO(1)
- BO(n)
- CO(n²)
- DO(log n)
6.Medium
Dynamic programming is useful when a problem has:
- ANo subproblems at all, so it can be solved in one step
- BOnly random inputs
- CA single loop
- DOverlapping subproblems and optimal substructure
7.Hard
Using the master theorem, T(n) = 8T(n/2) + O(n²) solves to:
- AΘ(n² log n)
- BΘ(n³)
- CΘ(n log n)
- DΘ(n²)
8.Hard
Why does binary search not give O(log n) time on a singly linked list?
- AReaching the middle element takes O(n) steps, since there is no direct index access
- BLinked lists cannot be sorted
- CBinary search needs at least twice the memory
- DComparisons on linked list nodes are slower
Answer key
- 1. C · O(V + E)
- 2. A · O(log n)
- 3. D · The array must be sorted
- 4. C · O(n)
- 5. A · O(1)
- 6. D · Overlapping subproblems and optimal substructure
- 7. B · Θ(n³)
- 8. A · Reaching the middle element takes O(n) steps, since there is no direct index access
Full step-by-step solutions: practise this topic on examproblems.com.