48 Chap. 7 Internal Sorting • Conceptually (in particular, the linked list version) Mergesort is stable. The array implementations are NOT stable, since, given that the sublists are stable, the merge operation will pick the element from the lower list before the upper list if they are equal. This is easily modi f ed to replace “less than” with “less than or equal to.” • Heapsort is NOT stable. Elements in separate sides of the heap are processed independently, and could easily become out of relative order. • Binsort is stable. Equal values that come later are appended to the list. • Radix Sort is stable. While the processing is from bottom to top, the bins are also f lled from bottom to top, preserving relative order. 7.7 In the worst case, the stack can store n records. This can be cut to log n in the worst case by putting the larger partition on FIRST, followed by the smaller. Thus, the smaller will be processed
This is the end of the preview. Sign up
access the rest of the document.
This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.