How does Radix Sort work?

前端 未结 4 1460
感动是毒
感动是毒 2021-01-30 08:48

I don\'t know why this is so hard for me to wrap my head around. I\'ve looked through the wiki pages, and pseudo code (as well as actual code) trying to understand how radix so

4条回答
  •  猫巷女王i
    2021-01-30 09:23

    This is the basic flow of quicksort.

    For 1st pass: we sort the array on basis of least significant digit (1s place) using counting sort. Notice that 435 is below 835, because 435 occurred below 835 in the original list.

    For 2nd pass: we sort the array on basis of next digit (10s place) using counting sort. Notice that here 608 is below 704, because 608 occurred below 704 in the previous list, and similarly for (835, 435) and (751, 453).

    For 3rd pass: we sort the array on basis of most significant digit (100s place) using counting sort. Notice that here 435 is below 453, because 435 occurred below 453 in the previous list, and similarly for (608, 690) and (704, 751).

    For more details you can refer to this blog on codingeek and have clear understanding.

提交回复
热议问题