# Class 12: Sorting, Revisited

Back to Sorting. On to Background for Ethical Issues.

Held Friday, February 11, 2000

Overview

Today, we conclude our initial study of algorithms by investigating a final sorting algorithm typically known as Quicksort. We then consider some of the implications of the focus of many programmers and computer scientists on efficiency.

Question 12 for today's class: Computer programmers often emphasize efficiency as the primary criterion for evaluating algorithms. What effects do you think this emphasis has?

Question 13 for Monday's class: What implication of computing do you most want to consider this semester? Why?

Notes

• Today we meet in 2424.
• I should get initial comments on your work to you on Monday.
• For Monday, read Chapter 1 of Forester and Morrison

Contents

Summary

• Sorting, revisited
• A divide-and-conquer algorithm for sorting
• Reflection:
• What are strengths and weaknesses of the emphasis on efficiency?
• What can computer scientists to to ameliorate these weaknesses?
• Handouts:
• Your answers to question 12: Computer programmers often emphasize efficiency as the primary criterion for evaluating algorithms. What effects do you think this emphasis has?

## Quicksort

• So far, all of our sorting algorithms are O(n2)
• Can we do better?
• For searching, we found that a divide and conquer strategy helped.
• Can we apply a similar strategy to searching?
• In fact, some of you suggested a simliar strategy. Just as we did for searching, I'm going to try to generalize that strategy.
```To sort a collection
1. Make two new piles, which we'll call small and large
2. Step through the collection
a. Put small things in the small pile
b. Put large things in the large pile
3. Sort each pile separately
4. Put them back together
```

## Reflections

• We conclude our study of algorithms by reflecting on various issues.
• What have you learned so far?
• What are your reactions to this emphasis on efficiency?
• ...

## History

Saturday, 22 January 2000

• Created as a blank outline.

Friday, 11 February 2000

• Filled in the details.

Back to Sorting. On to Background for Ethical Issues.

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.