 
Summary: Sorting Page 1
Chapter 7
Sorting
Terminology
Internal sort done totally in main memory.
External uses auxiliary storage (disk).
Stable retains original order if keys are the same. In asking if a sort is stable, we are
asking can it be reasonably coded to be stable.
Adaptive (NonOblivious) takes advantage of existing order to do less work.
Sort by address uses indirect addressing so the record (structure) doesn't have to be
moved.
Inversion a pair of elements that is out of order. Important in determining a lower
bound. The number of pairs of elements is
2
)1( nn
(n ways to pick first, n1 ways to
pick the second, divide by two as order isn't important). On average, only half of these
pairs are out of order, so number of inversions is
4
)1( nn
