Unit07C

Unit07C - Comparison Sorts Sorting Non-comparison Sorts...

This preview shows pages 1–2. Sign up to view the full content.

1 1 Sorting Non-comparison Sorts Sorting in the Java API 7C 2 Comparison Sorts All of the sorts we've seen so far are comparison sorts. The order of the elements is determined by comparing two elements at a time. It has been proven that the worst-case order of complexity for comparison sorts is Ω (n log n). O gives an asymptotically upper bound on the efficiency. Ω gives an asymptotically lower bound on the efficiency. (more about this in 15-211) But there are sorts that can sort in O(n). .. ... they just don't use pair-wise comparisons 3 Bucket Sort Given an array of n elements that contain only k unique values (k < n), labeled n 1 , n 2 , . .., n k such that n 1 < n 2 < . .. < n k . Create an array of k "buckets", one for each unique value. For each value in the array, move it into its corresponding bucket. Copy the data values from each bucket, n 1 to n k , back into the array to sort the data. 4

This preview has intentionally blurred sections. Sign up to view the full version.

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

{[ snackBarMessage ]}

Page1 / 2

Unit07C - Comparison Sorts Sorting Non-comparison Sorts...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online