Sorting with RADIX & COUNTING: How to?

In summary, Radix Sort uses Counting Sort as a subroutine to sort each letter of the words in the list one at a time, starting from the least significant character.
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! :eek:

I have to describe the operation of the processure "RADIX SORT" at the following list of words:

[m]COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOX[/m]
When I want to show the work of the algorithm RADIX SORT do I have to sort the letters by comparing them or do I have to show also the work of COUNTING SORT ?? (Wondering) In my book there is the following algorithm of Radix Sort:

Code:
RADIX_SORT(A, d) 
      for i ← 1 to d 
          sort A as for the digit i with a stable algorithm

The algorithm of Counting Sort is the following:

Code:
COUNTING_SORT (A, B, k)
    
    for i ← 0 to k do
        c[i] ← 0
    for j ← 1 to length[A] do
        c[A[j]] ← c[A[j]] + 1
    //c[i] now contains the number of elements equal to i
    for i ← 1 to k do
        c[i] ← c[i] + c[i-1]
    // c[i] now contains the number of elements ≤ i
    for j ← length[A] downto 1 do
        B[c[A[j]]] ← A[j]
        c[A[j]] ← c[A[j]] - 1
 
Technology news on Phys.org
  • #2
Radix Sort uses Counting Sort as a subroutine so you will need to show the work of both algorithms to demonstrate the process of sorting the list of words. The Radix Sort works by sorting the characters of each word by comparing them one at a time, starting from the least significant character. The algorithm first sorts the list of words based on the first letter of each word, then it continues with the second letter of each word and so on until all the letters of each word have been sorted. To do this, the algorithm uses Counting Sort to sort each letter. For example, for the list of words given, the first step would be to sort them based on their first letter, so we'd have: BOX, BAR, BIG, COW, DIG, DOG, EAR, FOX, MOB, NOW, ROW, RUG, SEA, TAB, TAR, TEA. Then we'd move on to the second letter, so we'd have: BAR, BOX, BIG, COW, DIG, DOG, EAR, FOX, MOB, NOW, ROW, RUG, SEA, TAB, TAR, TEA. We'd continue this process until each word is sorted.
 

Related to Sorting with RADIX & COUNTING: How to?

1. What is sorting with RADIX and COUNTING?

Sorting with RADIX and COUNTING is a method of arranging a set of data in a specific order by using the digits or characters of the data. It is a non-comparative sorting algorithm that sorts the data based on their individual digits or characters rather than comparing them to each other.

2. How does sorting with RADIX and COUNTING work?

In RADIX and COUNTING sorting, the data is sorted by creating buckets for each digit or character and placing the data into their respective buckets. Then, the data is gathered from the buckets in order, starting from the lowest digit or character to the highest, resulting in a sorted list.

3. What are the advantages of using RADIX and COUNTING sorting?

RADIX and COUNTING sorting has several advantages, including its efficiency in sorting large data sets, its ability to handle both integers and strings, and its stability, meaning that it preserves the relative order of equal elements in the original data set.

4. Are there any limitations to sorting with RADIX and COUNTING?

One limitation of RADIX and COUNTING sorting is that it can only be used for data sets with a fixed number of digits or characters. It also requires extra space to store the buckets, making it less efficient for smaller data sets.

5. Can RADIX and COUNTING sorting be used for any type of data?

Yes, RADIX and COUNTING sorting can be used for both numerical and alphabetical data. However, for alphanumeric data, the data must be converted to a numerical equivalent before using this sorting method.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
Replies
9
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
31
Views
2K
  • Programming and Computer Science
Replies
15
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top