{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW4 - Fall Semester 2008 CS300 Algorithms Homework#4(due...

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

View Full Document Right Arrow Icon
Fall Semester 2008 CS300 Algorithms Homework #4 (due 10/23) 1. Quick Sort is not a stable sorting algorithm. However if the key in A ( i ) is changed to A ( i ) * n + i - 1 then it can be stable. ( n is the number of elements in A ) (a) Show that Quick Sort can be a stable sorting algorithm using this transformation. (b) After sorting, what transformation will restore the keys back to their original values? 2. Insertion sort on small arrays in merge sort Although merge sort runs in O ( n lg n ) worst-case time and insertion sort runs in O ( n 2 ) worst case time, the constant factors in insertion sort make it faster for small n . Thus, it makes sense to use insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of length k are sorted using insertion sort and then merged using the standard merging mechanism, where k is a value to be determined. (a) Show that the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online