1.Easy
What are the three steps of a divide-and-conquer algorithm?
- ADivide, conquer, combine
- BGuess, check, repeat
- CSort, search, return
- DRead, compute, write
2.Easy
Which notation describes an upper bound on growth?
- ABig Omega
- BLittle omega
- CBig O
- DBig Theta
3.Easy
Which sorting algorithm repeatedly swaps adjacent elements that are in the wrong order?
- AHeap sort
- BMerge sort
- CQuicksort
- DBubble sort
4.Medium
What does amortised analysis measure?
- AThe average cost per operation over a worst-case sequence of operations
- BThe cost of the single most expensive operation anywhere in the sequence
- CThe cost of an algorithm on the best input
- DThe expected cost over random inputs
5.Medium
How many levels does the recursion of merge sort have for an array of n elements?
- AAbout n
- BAbout log₂ n
- CAbout n / 2
- DAbout √n
6.Medium
Why do many library sorting routines switch to insertion sort for very small subarrays?
- AInsertion sort uses less memory than any other sorting algorithm on large inputs
- BInsertion sort is O(n log n) in the worst case
- CInsertion sort has little overhead and is fast on small or nearly sorted inputs
- DRecursive algorithms cannot handle arrays below 10 elements
7.Hard
What would follow if someone found a polynomial-time algorithm for one NP-complete problem?
- AOnly that one problem would move into P
- BThe halting problem would become decidable
- CAll exponential-time algorithms would immediately run in linear time
- DEvery problem in NP could be solved in polynomial time, so P = NP
8.Hard
The halting problem shows that:
- ASome programs run faster on faster computers, so halting depends on hardware
- BEvery program eventually halts
- CLoops should be avoided
- DNo algorithm can decide for every program and input whether it halts
Answer key
- 1. A · Divide, conquer, combine
- 2. C · Big O
- 3. D · Bubble sort
- 4. A · The average cost per operation over a worst-case sequence of operations
- 5. B · About log₂ n
- 6. C · Insertion sort has little overhead and is fast on small or nearly sorted inputs
- 7. D · Every problem in NP could be solved in polynomial time, so P = NP
- 8. D · No algorithm can decide for every program and input whether it halts
Full step-by-step solutions: practise this topic on examproblems.com.