# Union Area Calculation

1 Pages188 Words190 Views
|
|
|
Area of rectangles union-Given N rectangles with edges parallel to axis, calculate the area of the union of all rectangles.-A rectangle is specified by giving its smallest and largest x- and y-coordinates x1, x2, y1, y2, where x1 < x2 and y1 < y2.-Bottom left corner is at (x1, y1) and the upper right corner at (x2, y2).-The area of this rectangle is given by the formula (x2 – x1)*(y2 – y1)Rectangles may intersect each other or may even be inside each other.-The task is to write a program in Java that reads n rectangles and return the total area.-The complexity should not be O(n2). The format of the input is:-<Number of rectangles>-<x1> <x2><y1>y2>-<x1> <x2><y1>y2>-......Output file should contain 1 number - the resulting area of the rectangles' union

## End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents

### Support

#### +1 306 205-2269

Chat with our experts. we are online and ready to help.