1.Easy
What is the time complexity of finding the largest value in an unsorted array of n numbers?
- AO(log n)
- BO(n)
- CO(1)
- DO(n log n)
2.Easy
Which complexity class grows fastest for large n?
- AO(n³)
- BO(n²)
- CO(2ⁿ)
- DO(n log n)
3.Easy
Which of these grows slowest as n becomes large?
- AO(n²)
- BO(n)
- CO(log n)
- DO(n log n)
4.Medium
How many levels does the recursion of merge sort have for an array of n elements?
- AAbout n
- BAbout √n
- CAbout log₂ n
- DAbout n / 2
5.Medium
Which sorting algorithm is stable?
- AMerge sort
- BQuicksort (typical in-place version)
- CHeap sort
- DSelection sort (typical version)
6.Medium
What does amortised analysis measure?
- AThe expected cost over random inputs
- BThe cost of the single most expensive operation anywhere in the sequence
- CThe average cost per operation over a worst-case sequence of operations
- DThe cost of an algorithm on the best input
7.Hard
The halting problem shows that:
- AEvery program eventually halts
- BNo algorithm can decide for every program and input whether it halts
- CSome programs run faster on faster computers, so halting depends on hardware
- DLoops should be avoided
8.Hard
Which technique gives an expected O(n log n) running time for quicksort on any input?
- AChoosing the pivot uniformly at random
- BAlways choosing the first element
- CUsing recursion only on the left side
- DSorting the input before running quicksort
Answer key
- 1. B · O(n)
- 2. C · O(2ⁿ)
- 3. C · O(log n)
- 4. C · About log₂ n
- 5. A · Merge sort
- 6. C · The average cost per operation over a worst-case sequence of operations
- 7. B · No algorithm can decide for every program and input whether it halts
- 8. A · Choosing the pivot uniformly at random
Full step-by-step solutions: practise this topic on examproblems.com.