- #1
mathmari
Gold Member
MHB
- 5,049
- 7
Hey!
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:
The algorithm of Counting Sort is the following:
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