So far I have an array of 2D points, (x_i, y_i). In the first step I create an array sorted by x-coordinate and array sorted by y-coordinate. Then I split x-sorted array in two halves.
How do I reconstruct from these two halves the corresponding two halves of y-sorted array without sorting by y-coordinate again.
It seems that it is possible in linear time and should be quite easy. Thanks.
So far I have an array of 2D points, (x_i, y_i). In the first
Share
In pseudocode:
If you add p to the end of each “half set”, then the sort order of “sorted-by-y” will be maintained.