Questions tagged [radix-sort]

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

307 questions
205
votes
15 answers

In-Place Radix Sort

This is a long text. Please bear with me. Boiled down, the question is: Is there a workable in-place radix sort algorithm? Preliminary I've got a huge number of small fixed-length strings that only use the letters “A”, “C”, “G” and “T” (yes, you've…
Konrad Rudolph
  • 482,603
  • 120
  • 884
  • 1,141
59
votes
7 answers

Radix sort vs Counting sort vs Bucket sort. What's the difference?

I am reading the definitions of radix, counting and bucket sorts and it seems that all of them are just the code below: public static void sort(int[] a, int maxVal){ int [] bucket=new int[maxVal+1]; for (int i=0; i
good_evening
  • 19,773
  • 60
  • 178
  • 288
52
votes
6 answers

Why quicksort is more popular than radix-sort?

Why quicksort(or introsort), or any comparison-based sorting algorithm is more common than radix-sort? Especially for sorting numbers. Radix-sort is not comparison based, hence may be faster than O(nlogn). In fact, it is O(kn), where k is the number…
Daniyar
  • 1,520
  • 2
  • 14
  • 23
51
votes
12 answers

When should we use Radix sort?

It seems Radix sort has a very good average case performance, i.e. O(kN): http://en.wikipedia.org/wiki/Radix_sort Yet it seems like most people are still using Quick Sort - why is this?
Howard
  • 17,155
  • 33
  • 104
  • 173
47
votes
2 answers

What is the difference between bucket sort and radix sort?

Bucket sort and radix sort are close cousins; bucket sort goes from MSD to LSD, while radix sort can go in both "directions" (LSD or MSD). How do both algorithms work, and in particular how do they differ?
Lazarus
  • 471
  • 1
  • 4
  • 4
40
votes
4 answers

How does Radix Sort work?

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 sort algorithms work (with respect to buckets). Am I looking into the wrong…
MrDuk
  • 12,340
  • 13
  • 55
  • 113
21
votes
3 answers

Radix sort: LSD versus MSD versions

The book "Introduction to Algorithms" mentions about the LSD (Least Significant Digit) version of radix sort. However , as others have pointed out here in stackoverflow, a MSD (Most Significant Digit) version also exists. So I want to know the pros…
Geek
  • 23,609
  • 39
  • 133
  • 212
16
votes
10 answers

Radix Sort for Negative Integers

I am trying to implement radix sort for integers, including negative integers. For non-negative ints, I was planning to create a queue of 10 queues correspondingly for the digits 0-9 and implement the LSD algorithm. But I was kind of confused with…
gtkesh
  • 391
  • 1
  • 2
  • 10
14
votes
2 answers

Radix Sort, Sorting a float data

Is radix sort capable of sorting float data for example 0.5, 0.9, 1.02, etc.?
BGV
  • 201
  • 3
  • 5
12
votes
3 answers

Why does radix sort have a space complexity of O(k + n)?

Consider an array with n numbers that has maximum k digits (See Edit). Consider the radix sort program from here: def radixsort( aList ): RADIX = 10 maxLength = False tmp, placement = -1, 1 while not maxLength: maxLength = True #…
skr_robo
  • 770
  • 13
  • 31
10
votes
5 answers

Is there a good radixsort-implementation for floats in C#

I have a datastructure with a field of the float-type. A collection of these structures needs to be sorted by the value of the float. Is there a radix-sort implementation for this. If there isn't, is there a fast way to access the exponent, the sign…
Willem Van Onsem
  • 321,217
  • 26
  • 295
  • 405
10
votes
2 answers

Sort n numbers between [0,n^2 - 1] in O(n)?

Possible Duplicate: An array of length N can contain values 1,2,3 … N^2. Is it possible to sort in O(n) time? Given n numbers at the range [0,n^2 -1] how can we sort them in O(n) run time ? I have a feeling that the solution involves radix sort…
JAN
  • 18,509
  • 49
  • 147
  • 268
9
votes
3 answers

Pushing Radix Sort (and python) to its limits

I've been immensely frustrated with many of the implementations of python radix sort out there on the web. They consistently use a radix of 10 and get the digits of the numbers they iterate over by dividing by a power of 10 or taking the log10 of…
reem
  • 6,748
  • 4
  • 15
  • 26
8
votes
3 answers

An array of length N can contain values 1,2,3 ... N^2. Is it possible to sort in O(n) time?

Given an array of length N. It can contain values from ranging from 1 to N^2 (N squared) both inclusive, values are integral. Is it possible to sort this array in O(N) time? If possible how? Edit: This is not a homework.
riderchap
  • 639
  • 1
  • 10
  • 19
8
votes
3 answers

Why bother with comparison sorts?

Algorithms like Timsort, Quicksort & Mergesort dominate the "real world" sorting methods. The case for these comparison sorts is quite practical — they've been shown to be the most performant, stable, multipurpose sorting algorithms in a wide…
ŹV -
  • 2,391
  • 1
  • 18
  • 28
1
2 3
20 21