0% found this document useful (0 votes)
57 views1 page

CS2001 Week 10 Tutorial: Sorting (With Some Complexity)

This document discusses sorting algorithms and their complexities. It covers divide and conquer algorithms like merge sort, sources of bugs in divide and conquer approaches, how a partial ordering would affect merge sort, comparisons of bubble sort and insertion sort, why the fastest general sorting algorithms have O(n log n) complexity, advantages and disadvantages of value-driven versus structural algorithms, and approaches to picking pivots in quicksort.

Uploaded by

Abhishek Gambhir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views1 page

CS2001 Week 10 Tutorial: Sorting (With Some Complexity)

This document discusses sorting algorithms and their complexities. It covers divide and conquer algorithms like merge sort, sources of bugs in divide and conquer approaches, how a partial ordering would affect merge sort, comparisons of bubble sort and insertion sort, why the fastest general sorting algorithms have O(n log n) complexity, advantages and disadvantages of value-driven versus structural algorithms, and approaches to picking pivots in quicksort.

Uploaded by

Abhishek Gambhir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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