Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using C++, 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
Using C++, 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. Here is the radix sort of chapter 11.2.3
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 ofcards. This time you pick up the cards one at a time and arrange them by rank into 13 possible groups in this order: 2,3,..., 10, J, Q, K,A. 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 letterStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started