1. When doing LSD Radix Sort on numbers, a trick to making the number of digits be equal is to
assign
leading
zeroes to the smaller numbers. For example, the data set {3, 50, 123, 66, 9}
becomes {003, 050, 123, 066, 009}.
Can you do the same thing with LSD Radix on lowercase English words? Why or why not? If
not, show a counterexample and provide an alternative. Use # to be a symbol that is less than all
lowercase letters (e.g. {a, ab} becomes {#a, ab} if we use leading #).
No, this method would not work for strings. Consider the data set {#z,
ab}. In LSD’s first pass, it will have ab before #z. However, in the
second (and last) pass, it will have #z and ab, which is illegal since z
occurs after ab in alphabetical order.
An alternative solution that works is using trailing #’s instead. For
example, {z#, ab} will sort correctly. Note that this is very similar to
how you handled strings for MSD in the homework. Bucket[0]
contained strings that didn’t have a character at a certain index.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '10
 Sweat,Monica
 Algorithms, Data Structures, Sort, Insertion Sort

Click to edit the document details