You are on page 1of 1

CS2001 week 10 tutorial:

Sorting (with some complexity)

1. What is a divide and conquer algorithm? Explain the idea in general and illustrate with the
specific example of merge sort.
2. Explain the likely sources of bugs when designing a divide and conquer “algorithm” – the
places you're most likely to end up with something non-algorithmic. How would you protect
yourself against them?
3. Suppose that, instead of a total ordering, we provided a partial ordering to merge sort. So if
a < b, a should appear before b in the result; but if a and b are incomparable under the
partial ordering, we don't care what order they come in with respect to each other. Explain
what might change in this case (if anything), and what would happen to the complexities (if
anything).
4. The Bubble sort algorithm is yet another kind of sort. Compare and contrast it with insertion
sort: how is it different? Will these differences make any difference to the time or space
complexities involved? Why might you use bubble sort instead of (for example) in-place
quicksort?
5. The fastest general sorting algorithms have average time complexity O(n log n). Where is
this logarithmic behaviour coming from?
6. Merge sort is a purely structural sort procedure; quicksort's execution is much more
influenced by the actual elements in the sequence being sorted. What are the potential
advantages and disadvantages of value-driven vs purely structural algorithms? – in general,
not specifically for these two sorting algorithms.
7. Explain the structural, random, and median-of-three approaches to picking the pivot in
quicksort. Is there anything to choose between them?

You might also like