pereges wrote:
> I've an array :
>
> {100,20, -45 -345, -2 120, 64, 99, 20, 15, 0, 1, 25}
>
> I want to split it into two different arrays such that every number <=
> 50 goes into left array and every number > 50 goes into right array.
> I've done some coding but I feel this code is very inefficient:
This looks like just a sort.
But instead of comparing the element value data[i], compare (data[i]<50)
instead (so you are effectively comparing lots of 0's and 1's).
I got these results with such a sort:
Before = ( 100, 20, -45, -345, -2, 120, 64, 99, 20, 15, 0, 1, 25)
After = ( 1, -2, 15, 0, 20, 25, -345, -45, 20, 120, 100, 99, 64)
--
Bartc
|