Академический Документы
Профессиональный Документы
Культура Документы
one would probably start out sorting from the most significant
digit, and descend to the least significant digit:
(human sorter)
450
720 411 497 329
#0 #1 #2 #3 #4 #5 #6 #7 #8 #9
450
720 411 497 329
#0 #1 #2 #3 #4 #5 #6 #7 #8 #9
720 450 411 497 329 target[] This completes the first pass.
We then process the second digit using the same procedure.
329
411 720 450 497
#0 #1 #2 #3 #4 #5 #6 #7 #8 #9
Repeat the same procedure on the next unsorted digit until every digit is sorted.
Technicalities:
1)The bins are implemented using arrays of queues,
and each queue contains integers.
2)
bins[1] represents bin#1
#1
411
bins[1].Enqueue(411);
#1
4) similarly, use bins[1].Dequeue() to get one number out of bin#1.
Radix sort using queues An example of sorting 2-digit integers.
Queue<int> bins[10];