1.Easy
Which design strategy does merge sort use?
- ADivide and conquer
- BBrute force
- CDynamic programming
- DGreedy choice
2.Easy
How does selection sort work?
- AIt repeatedly finds the minimum of the unsorted part and swaps it to the front
- BIt inserts each element into a growing sorted part by shifting
- CIt repeatedly swaps neighbouring elements that are in the wrong order
- DIt splits the array in halves and merges them
3.Easy
How much extra memory does a standard array-based merge sort use?
- AO(log n)
- BO(1)
- CO(n)
- DO(n²)
4.Medium
How many levels does the recursion of merge sort have for an array of n elements?
- AAbout √n
- BAbout n / 2
- CAbout n
- DAbout log₂ n
5.Medium
How does Prim's algorithm build a minimum spanning tree?
- AIt sorts all edges by weight and adds each one unless it would form a cycle in the forest
- BIt removes the most expensive edge until no cycles remain
- CIt grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- DIt runs breadth-first search and keeps the BFS tree
6.Medium
A recurrence T(n) = 2T(n/2) + O(n) solves to:
- AO(n)
- BO(log n)
- CO(n²)
- DO(n log n)
7.Hard
Why is the average lookup in a hash table O(1) but the worst case O(n)?
- AArrays have O(n) access
- BKeys must be sorted first
- CHash functions are slow
- DMany keys may collide into the same bucket
8.Hard
Which technique gives an expected O(n log n) running time for quicksort on any input?
- AChoosing the pivot uniformly at random
- BUsing recursion only on the left side
- CSorting the input before running quicksort
- DAlways choosing the first element
Answer key
- 1. A · Divide and conquer
- 2. A · It repeatedly finds the minimum of the unsorted part and swaps it to the front
- 3. C · O(n)
- 4. D · About log₂ n
- 5. C · It grows one tree from a start vertex, adding the cheapest edge that leaves the tree
- 6. D · O(n log n)
- 7. D · Many keys may collide into the same bucket
- 8. A · Choosing the pivot uniformly at random
Full step-by-step solutions: practise this topic on examproblems.com.