Question: Progam in C++ : :::Answere the following question: Implement the radix sort of an array by using a queue for each group. The radix sort



Progam in C++ ::::Answere the following question: Implement the radix sort of an array by using a queue for each group.
The radix sort is discussed in Section 11.2.3 of Chapter 11 of your textbook. You can get more information in Radix sort. RADIX SORT OF CHAPTER 11: // Sorts n d-digit integers in the array theArray. radixSort(theArray: ItemArray, n: integer, d: integer): void for (j = d down to 1) { Initialize 10 groups to empty Initialize a counter for each group to 0 for (i = 0 through n - 1) Group the strings by their middle letter { k = jth digit of theArray[i] Place theArray[i] at the end of group k Increase kth counter by 1 } Replace the items in theArray with all the items in group 0, followed by all the items in group 1, and so on.
11.2.3 The Radix Sort The radix sort is included here because it is quite different from the other sorts we've described, as it does not compare the array's entries Imagine again that you are sorting a hand of cards. This time you pick up the cards one at a time and arrange them by rank into 1 3 possible groups in this order: 2, 3, . . . , 10, J, Q, KA Combine these groups and place the cards face down on the table so that the 2s are on top and the aces are on the bottom. Now pick up the cards one at a time and arrange them by suit into four possible groups in this order: clubs, diamonds, hearts, and spades. When taken together, the groups result in a sorted hand of cards A radix sort uses this idea of forming groups and then combining them to sort a collection of data. The sort treats each data item as a character string. As a first simple example of a radix sort, con- sider this collection of three-letter strings: ABC, XYZ, BWZ, AAC, RLT, JBX, RDT, KLT, AEO, TLJ The sort begins by organizing the data according to the rightmost (least significant) letters. Although none of the strings ends in A or B, two strings end in C. Place those two strings into a group. Continu- ing through the alphabet, you form the following groups (ABC, AAC) (TLJ) (AEO) (RLT, RDT, KLT) (JBX) (XYZ, BWZ) Group strings by their rightmost letter The strings in each group end with the same letter, and the groups are ordered by that letter. In addi- tion, the strings within each group retain their relative order from the original list of strings Now combine the groups into one as follows. Take the items in the first group in their present order, follow them with the items in the second group in their present order, and so on. The following group results ABC, AAC, TLJ, AEO, RLT, RDT, KLT, JBX, XYZ, BWZ Combine the groups Next, form new groups as you did before, but this time use the middle letter of each string instead of the last letter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
