Question: 1.3 Three Pile Radix sort Radix sort works for strings over larger alphabets than five characters - just use more piles but at some point

 1.3 Three Pile Radix sort Radix sort works for strings overlarger alphabets than five characters - just use more piles but at

1.3 Three Pile Radix sort Radix sort works for strings over larger alphabets than five characters - just use more piles but at some point it seems wasteful to have so many piles. Many might be empty. Rather than using more piles, let's consider using less. Following Quicksort's approach, we could pick a character p from the alphabet and partition the strings into those whose first character is less than p, those whose first character equals p, and those whose first character is greater than p. Three piles! The middle pile is exactly the same as the pile for character p in radix sort. The first and last pile are like the two partitions formed using p as the pivot in quicksort. (a) (3 points) Fill in the blanks in the following pseudo-code to supply the appropriate value of j to the recursive calls P3RadixSort(vector S, int j) 1. If S contains 0 or 1 string, return 2. Pick a pivot character p 3. Divide S into three piles: Pc: strings whose jth character is less than p P: strings whose jth character equals p P: strings whose jth character is greater than p 4. P3RadixSort(P 5. P3RadixSort(P-, 6. P3RadixSort(P 7. Copy (the now sorted) Ps, P, P back into S in that order (b) (6 points) The following recursion tree shows the execution of P3RadixSort on the set of strings in problem 1.2. The circles contain the number of strings passed to the subproblem (the root represents the initial problem of sorting 8 strings). The "j-o" next to the circle is the value of j passed to the subproblem (0 for the initial problem) The character b below the circle is the pivot character p chosen by the subproblem to divide the strings into three piles, which are the three children of the root. Your job is to complete the recursion tree by supplying the j values and pivot values for all the nodes except the root (which is given) and the leaves (which have no children) 011 011

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!