Final answer:
The described problem requires creating non-crossing pairings between points in a plane, utilizing a divide and conquer algorithm similar to finding the closest pair of points. The algorithm involves sorting, recursively pairing, checking for potential crossings, and merging pairs in O(n^2 lg n) time.
Step-by-step explanation:
The problem described is one of computational geometry, specifically related to the pairing of points (representing Ghostbusters and ghosts) in the plane so that the lines (streams) connecting the pairs do not cross. An O(n^2 lg n)-time algorithm to solve this can be designed by utilizing a divide and conquer strategy similar to the one used in the closest pair of points problem.
- Sort all the points by their x-coordinates.
- Divide the set of points into two halves by drawing a vertical line through the median x-coordinate.
- Recursively pair off Ghostbusters and ghosts in each half. Ensure that each pair consists of one Ghostbuster and one ghost from the same half.
- Find potential cross-stream pairs by examining Ghostbusters and ghosts that are close to the dividing line. This step identifies pairs that may cause crossing streams after the recursive step.
- For each Ghostbuster on one side of the dividing line, pair with the closest ghost on the other side such that the pair does not cause a stream cross with already established pairs. Utilize a data structure to dynamically check for intersections while pairing.
- Repeat this for all unpaired Ghostbusters adjacent to the dividing line.
- Merge the pairs from both halves along with the Ghostbuster-ghost pairs across the divide.
Steps 4 to 6 are critical in ensuring that no streams cross and contribute to the O(n lg n) complexity for pairing across the divide. The overall complexity is O(n^2 lg n) due to the recursive nature of the algorithm and the added complexity of checking for crossing streams.