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
In reply to Encoding function needed by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |