Qbasicnews.com
Odd radix sort problem - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: General (http://qbasicnews.com/newforum/forum-6.html)
+--- Forum: General/Misc (http://qbasicnews.com/newforum/forum-18.html)
+---- Forum: General Programming (http://qbasicnews.com/newforum/forum-20.html)
+---- Thread: Odd radix sort problem (/thread-8911.html)



Odd radix sort problem - wallace - 02-20-2006

Quote:For the radix sort, use a straightforward iterative approach, using at most 2 1D arrays (not linked lists)

This is part of a project I'm supposed to code. I don't even understand how this is supposed to work. I use radix sorts all the time, but I almost always use Linked Lists, and if I don't I use 2, 10, or 16 buckets for EACH iteration, how can I do an entire radix sort in only one extra linear array? Could someone help me out with some psydo-code here?


Odd radix sort problem - na_th_an - 02-20-2006

I think it's just a matter of simulating linked lists within a 1D array (hate that way to call them, they are actually called vectors). I.e. when you add a value you have to shift right the ones that are supposed to be after and when you take a value away you have to shift them left.


Odd radix sort problem - Moneo - 02-22-2006

Does this project insist that you use a radix sort, or is your task to provide a good, working sort?
*****


Odd radix sort problem - wallace - 02-24-2006

It must be a radix sort, I'm still having trouble seeing it. Could someone please post some pseudocode?


Odd radix sort problem - Moneo - 02-25-2006

Quote:It must be a radix sort, I'm still having trouble seeing it. Could someone please post some pseudocode?

I did a Google search on "radix.sort" and found some interesting sites, like NIST. You might want to look at some of these for the pseudo-code that you're looking for.

Much to my surprise, a radix sort emulates the way we used to sort punched cards using a card sorting machine (sorter) back in the 1960's. What a radix sort calls "buckets" were called "pockets" on a sorter.

I have played around with similar sorts over the years. What complicates matters is whether you intend to sort strings or values, and if the strings contain only numbers or can be alphanumeric. Same problem applied on the sorter by the way.

Also, if the strings are only numbers, what is the maximum number of digits that any of these strings can have? This determines the number of passes over all the data.

I thing you need more detailed specs for the radix sort you need to write. Otherwise, if you attempt to write the sort to handle every case and data size, you're program will turn into a monster.
*****


Odd radix sort problem - wallace - 02-27-2006

My problem is not figuring out how a radix sort works, I use radix sort all the time. The problem is that I'm not allowed to use buckets.


Odd radix sort problem - Moneo - 02-27-2006

That's like being given a canoe, and not allowed to use paddles. :wink:
*****


Odd radix sort problem - na_th_an - 03-01-2006

As mentioned, you can emulate them with static structures such as arrays.