

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 license.
,a,…,a) 01 n- ^ Output: (b,b,…,b^01
) = permutation of S s.t. b n-
<= b i i+
CS575 lecture 8^ ^ Internal sorting: S is small enough to fit in memory/network^ ^ We concentrate on this ^ External sorting: S partly stored on external device (disk)^ ^ Job for MapReduce
☺ ^ Comparison sorting: Uses compares and exchanges^ ^ Ω(n log(n)) work ^ Non comparison sorting: Uses extra information about input data^ ^ Values lie in a small range (Radix Sort)^ ^ S is permutation of (1 .. N) (Pigeon hole sort)^ ^ Sometimes^ Ω
(n) work
CS575 lecture 8^
7 2 3 1 5 6 4 8^
8 7 6 5 4 3 2 1 2 |^^1 |^^6 |^^8 3 1^ | 7 |^^3 |^^5 |^^4
8 4^ 8 6 5 4 7 2 |^ 6 5^ 7 3 2 1 CS575 lecture 8^
7 |^^3 |^^5 |^^4 7 2^
|^ 6 5^ 7 3 2 1
CS575 lecture 8
m
1
1 1
1 CS575 lecture 8^ +^ +^ +^ + +^ +^ +^ +
1 3 5 7 8 6 4 2
11 32 44 23 85 66 58 77
1 2 3 4 5 6 7 8
CS575 lecture 8^
take minimum^ CS575 lecture 8 equal:^ take minimum unequal: take maximum for i = 0^ to d-1for j = i downto 0partner = flip bit (myLabel[j])exchange data with partnerif (myLabel[i+1] = = myLabel[j] )keep minelse keep max
|^ | CS575 lecture 8^ |^ |^
CS575 lecture 8^
CS575 lecture 8^ ^ left: elements <= pivot ^ right: elements > pivot Quicksort(left) Quicksort(right) Sequential complexity?