Data Str & Algorithm HW Solutions 48

Data Str & Algorithm HW Solutions 48 - 48 Chap. 7...

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

View Full Document Right Arrow Icon
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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online