baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
I'll go strait to the point. I am looking for a solution (not the code) to encode 1000 integers (positive), spanning from 1-10^9 into integers from 1-1000 so I can place them into a simple array data structure. Therefore, in order to avoid reinventing a wheel I was wondering does anyone know a solution to this problem and is willing to share?
An obvious approach would be sorting the numbers first and then assigning them to array positions according to their rank values. However, sorting only can be an option if the key size (like in counting sort) is less or equal to the array size, or sorting itself is linear in time, proportional to the array size. I cannot think of any such solution, so here I am?
thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Encoding function needed
by atcroft (Abbot) on Feb 08, 2015 at 10:53 UTC | |
|
Re: Encoding function needed
by roboticus (Chancellor) on Feb 09, 2015 at 12:05 UTC | |
|
Re: Encoding function needed
by wollmers (Scribe) on Feb 09, 2015 at 13:00 UTC | |
|
Re: Encoding function needed
by Anonymous Monk on Feb 08, 2015 at 19:49 UTC |