Questions tagged [radix-sort]

Radix sort is a sorting algorithm which sorts key/value pairs with integer keys by ordering digits.

307 questions
8
votes
4 answers

Radix Sorting with using queue

I've wanted to create a radix sort implementation using queues. I couldn't figure out which part of my code has problems or which resources should I read. My code may be totally wrong but this is my implementation without any help (I haven't taken…
mustafaSarialp
  • 265
  • 1
  • 7
  • 17
8
votes
3 answers

Radix Sort implemented in C++

I am trying to improve my C++ by creating a program that will take a large amount of numbers between 1 and 10^6. The buckets that will store the numbers in each pass is an array of nodes (where node is a struct I created containing a value and a…
GobiasKoffi
  • 3,754
  • 14
  • 54
  • 65
7
votes
1 answer

Why does R use radix sort?

From my understanding, R's order() method uses radix sort by default. This was not always the case (see news), but Matt Dowle made this presentation suggesting change because radix sort empirically performs well. My question is, why is radix sort…
Ben
  • 15,465
  • 26
  • 90
  • 157
7
votes
7 answers

Sort N numbers in digit order

Given a N number range E.g. [1 to 100], sort the numbers in digit order (i.e) For the numbers 1 to 100, the sorted output wound be 1 10 100 11 12 13 . . . 19 2 20 21..... 99 This is just like Radix Sort but just that the digits are sorted in…
Mor Eru
  • 1,069
  • 3
  • 18
  • 34
6
votes
1 answer

Optimizing radix sort in Haskell

I'm still learning Haskell and I wrote following radix sort function. It seems to work correctly, but the problem is that it is rather memory inefficient. If compiled with ghc, the memory goes highly over 500MB already with input list of size 10000…
Timo
  • 4,458
  • 3
  • 32
  • 37
6
votes
3 answers

MSD vs LSD radix sort

I'm not sure why would one ever use LSD radix sort. Advantages of MSD: It can handle strings of variable length It doesn't always need to scan the entire strings (it ca decide sooner about the order) One can use insertion sort to circumvent the…
user1377000
  • 1,313
  • 2
  • 14
  • 27
6
votes
1 answer

How to optimize an indirect radix sort? (a.k.a. how to optimize unpredictable memory access patterns)

I've written an indirect radix sort algorithm in C++ (by indirect, I mean it returns the indices of the items): #include #include #include template void radix_ipass( It1 begin, It1 const…
user541686
  • 189,354
  • 112
  • 476
  • 821
6
votes
3 answers

A fast, rank based Radix Sort for floats?

I'm searching for a fast stable radix sort implementation (with support of floats) which returns the indices of the sorted order instead of the sorted values. Pierre Terdiman's version from his article "Radix Sort Revisited" does exactly what I want…
plasmacel
  • 7,355
  • 5
  • 42
  • 87
6
votes
1 answer

Under what conditions do these non-comparison sorts run in linear time?

I am exploring the following algorithms: Counting Sort Radix Sort Bucket Sort I know all three are capable of running in linear time at best case, but I am having trouble with understanding when those cases occur, except in the case of counting…
ZAX
  • 918
  • 3
  • 19
  • 48
6
votes
2 answers

Sorting in linear time

I am reading introduction to algorithms 2nd edition, and there is a question says that we can sort n integers, who are between 0 and n3-1 in linear time. I am thinking of IBM's radix sort approach. I start with the least significant digit, separate…
yrazlik
  • 9,023
  • 26
  • 84
  • 145
5
votes
2 answers

Best way to get individual digits from int for radix sort in C/C++

What is the best way to get individual digits from an int with n number of digits for use in a radix sort algorithm? I'm wondering if there is a particularly good way to do it in C/C++, if not what is the general best solution? edit: just to…
bimbom22
  • 4,413
  • 2
  • 28
  • 46
5
votes
2 answers

Does C++ Algorithm/Boost Lib have Radix Sort?

I want to sort integers and I know radix sort is supposed to be awesome for it. Any library implementation for this sort?
AyBayBay
  • 1,558
  • 2
  • 17
  • 35
5
votes
2 answers

"In-place" MSD radix sort, stack space, and Stack Overflow's

I'm really confused the "in-place" MSD radix sort algorithm: Each bin is then processed recursively using the next digit, until all digits have been used for sorting. I'm confused because it seems to me that recursion implies O(n) stack space,…
user541686
  • 189,354
  • 112
  • 476
  • 821
4
votes
2 answers

How to use distribution sort (radix sort, etc) to sort strings?

I know how to use radix sort to sort integers. But how to use it to sort strings? or float numbers?
Jackson Tale
  • 23,820
  • 29
  • 135
  • 251
4
votes
2 answers

Why is my radix sort python implementation slower than quick sort?

I rewrote the original radix sort algorithm for Python from Wikipedia using arrays from SciPy to gain performance and to reduce code length, which I managed to accomplish. Then I took the classic (in-memory, pivot based) quick sort algorithm from…
hsk81
  • 792
  • 8
  • 14
1
2
3
20 21