comp2123 Assignment 5 s1 2023
Problem 1. We want to design a divide and conquer algorithm for computing
the union of a collection of rectangles. The input rectangles are aligned with
the axes and they are all stabbed by the y-axis. Each rectangle is represented
by the coordinates of its top-left and bottom-right corners, and the union is
representation by a sequence of interior-disjoint rectangles listed from top to
bottom. We require that no two consecutive rectangles in the representation can
be merged into a single rectangle.
For example, the union of the three rectangles on the left leads to the union
represented by the four rectangles on the right: