177k views
2 votes
Suppose we use radix sort to sort the English-language strings below using standard lexicographic ordering (i.e. sort in alphabetical order). We sort least-to-greatest and consider the numbers in top-to-bottom order when assigning them to bins. Assume the empty string" comes before all letters in lexicographic order. PART TRIP

TARP
ART
TRAP
CHIP

a) (1 point) How many passes are required to sort the strings?
b) (1 point) How many buckets would radix sort allocate to sort the strings?
c) (5 points) For each of the following pairs of words, fill in the circle next to the word that would appear earlier in the list after two passes of radix sort.
i) TRIP or TARP
CHIP or TRIP
iii) ART or PART
iv) PART or TARP
v) TARP or TRAP

d) State the runtime of radix sort on each of the following inputs set as precisely as you can. Include any known constant factors. i) (1 pt) Runtime on English-language strings of length d: ii) (1 pt) Runtime on decimal integers of length d:

1 Answer

5 votes

Answer:

a) 4 passes are required to sort the string.

b) 4

c) i) TARP

ii) CHIP

iii) PART

iv) TARP

v) TARP

d) O(k+n), n is no. of strings, k is largest no. of character in among the string

O(d*(n+10)), n is no. of integers

Step-by-step explanation:

Suppose we use radix sort to sort the English-language strings below using standard-example-1
Suppose we use radix sort to sort the English-language strings below using standard-example-2
User Christopher King
by
4.8k points