Sorting1.0 - Sorting Chapter 11 CSE 2011 Prof. J. Elder -1-...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sorting Chapter 11 CSE 2011 Prof. J. Elder -1- Last Updated: 4/1/10 11:16 AM Sorting Algorithms Comparison Sorting Selection Sort Bubble Sort Insertion Sort Merge Sort Heap Sort Quick Sort Linear Sorting Counting Sort Radix Sort Bucket Sort CSE 2011 Prof. J. Elder -2- Last Updated: 4/1/10 11:16 AM Comparison Sorts Comparison Sort algorithms sort the input by successive comparison of pairs of input elements. Comparison Sort algorithms are very general: they make no assumptions about the values of the input elements. 4 3 7 11 2 2 1 3 5 e.g.,3 11? CSE 2011 Prof. J. Elder -3- Last Updated: 4/1/10 11:16 AM Sorting Algorithms and Memory Some algorithms sort by swapping elements within the input array Such algorithms are said to sort in place, and require only O(1) additional memory. Other algorithms require allocation of an output array into which values are copied. These algorithms do not sort in place, and require O(n) additional memory. 4 3 7 11 2 2 1 3 5 swap CSE 2011 Prof. J. Elder -4- Last Updated: 4/1/10 11:16 AM Stable Sort A sorting algorithm is said to be stable if the ordering of identical keys in the input is preserved in the output. The stable sort property is important, for example, when entries with identical keys are already ordered by another criterion. (Remember that stored with each key is a record containing some useful information.) 4 3 7 11 2 2 1 3 5 1 2 2 3 3 4 5 7 11 CSE 2011 Prof. J. Elder -5- Last Updated: 4/1/10 11:16 AM ...
View Full Document

Ask a homework question - tutors are online