I need to explain how to modify radix sort, in order to sort n real numbers, when every number has O(1) digits.
General and short description is enough.
I thought of making the numbers to have same number of digits left and right to the decimal point, then sort with radix sort only the negative numbers and make sure they will be afterwards in the beginning of the array (before the non-negative numbers, can be implmented at O(n)).
Finally- sort the rest of the numbers with radix sort.
Is there anything wrong with that?
General and short description is enough.
I thought of making the numbers to have same number of digits left and right to the decimal point, then sort with radix sort only the negative numbers and make sure they will be afterwards in the beginning of the array (before the non-negative numbers, can be implmented at O(n)).
Finally- sort the rest of the numbers with radix sort.
Is there anything wrong with that?