radix-sort

Radix Sort for Negative Integers

淺唱寂寞╮ 提交于 2019-11-27 23:34:32
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 negative integers. What I am thinking now, is to go ahead and create another queue of 10 queues for them and separately sort them and then at the end, I will gave 2 lists, one containing negative ints sorted and the other containing non-negative ints. And finally I would merge them. What do you think about this? Is there more efficient way to handle

In-Place Radix Sort

故事扮演 提交于 2019-11-27 09:57:24
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 guessed it: DNA ) that I want to sort. At the moment, I use std::sort which uses introsort in all common implementations of the STL . This works quite well. However, I'm convinced that radix sort fits my problem set perfectly and should work much better in practice. Details I've tested this assumption with a very naive implementation and for

Why quicksort is more popular than radix-sort?

[亡魂溺海] 提交于 2019-11-27 08:49:06
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(n logn). In fact, it is O(k n), where k is the number of bits used to represent each item. And the memory overhead is not critical, since you may choose the number of buckets to use, and required memory may be less than mergesort's requirements. Does it have to do with caching? Or maybe accessing random bytes of integers in the array? Two arguments come to my mind: Quicksort/Introsort is more

Radix Sort for Negative Integers

假如想象 提交于 2019-11-27 04:40:51
问题 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 negative integers. What I am thinking now, is to go ahead and create another queue of 10 queues for them and separately sort them and then at the end, I will gave 2 lists, one containing negative ints sorted and the other containing non-negative

Radix Sort implemented in C++

核能气质少年 提交于 2019-11-26 14:46:25
问题 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 next node attribute). After sorting the numbers into buckets according to the least significant value, I have the end of one bucket point to the beginning of another bucket (so that I can quickly get the numbers being stored without disrupting the

Why quicksort is more popular than radix-sort?

你。 提交于 2019-11-26 14:18:56
问题 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(n logn). In fact, it is O(k n), where k is the number of bits used to represent each item. And the memory overhead is not critical, since you may choose the number of buckets to use, and required memory may be less than mergesort's requirements. Does it have to do with caching? Or maybe accessing